2,157 Posted Topics
Re: I'd make an interface or abstract question class. Let's go with interface for now: [code]interface IQuestion { String Text { get; } Boolean CheckAnswer(String ans); }[/code] Then you make up some question classes: [code]class RectangleQuestion : IQuestion { Random r = new Random(); int answer; public String Text { get … | |
Re: Move the } on line 45 to line 57. This will enclose the calculation in the 'else' part of your if statement. Indenting properly would show you why your problem is happening, most IDEs will do that for you. | |
Re: Sort recipeList before you output the XML. | |
Re: [URL="http://www.daniweb.com/code/snippet349476.html"]Combination Generation[/URL], the link to which was in the previous question you asked. | |
Re: Take a look at [url]http://www.daniweb.com/code/snippet349081.html[/url] | |
Re: 1) The name of the form is [icode]projdll.abc[/icode] 2) You'll want to read [URL="http://www.daniweb.com/forums/thread349598.html"]this[/URL] thread. | |
Re: Without seeing the application it's hard to tell what they might have done. | |
Re: I suspect it is your orderby clause. The running sum would be in order but you force an order by date, which throws off the sum. You'll probably have to do two queries: first that orders the data, second that generates the output. | |
Re: Winforms has broken support for transparent images. Unless you are willing to write your own control to deal with it, you'd be better off moving to WPF or XNA depending on what you are trying to do. | |
Re: Line 21 you declare that method static, then try to call a non-static method (DoCommand). Non-static methods require that you create an object of the class first so you have something that actually has the method. You can make all the DoCommand() methods static or you can create an object … | |
| |
Re: [URL="http://easywebcam.codeplex.com/"]Here[/URL] is a project to provide a class for manipulating a web camera. | |
Re: In the solution explorer right click on references and select Add Reference. Click the browse tab and browse to your DLL, select it and hit OK. Now you have access to the public classes of the DLL. Create a form from whatever class is in the DLL that contains your … | |
Re: [code]using System; using System.IO; namespace TestBed { class Program { static void Main(string[] args) { String[] lines = File.ReadAllLines("data.txt"); String[] first = lines[0].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); String[] second = lines[1].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < first.Length; i++) { Console.WriteLine("{0} … | |
Re: It sounds like you are using ClickOnce deployment and have failed to provide the files needed on a webserver (The URI giving the error is pointing to a local file on your machine). | |
Re: Just a comment about line 20 in your code above. You don't ever have to Flush a memory stream. It doesn't do anything. | |
Re: I'd ask whoever wrote the WebCam_Capture.dll if you are having issues with it. And what delay are you experiencing? Delay between frames, delay at start, what? | |
Re: A sample on how to color text. [code] private void button1_Click(object sender, EventArgs e) { string text1 = comboBox1.SelectedItem.ToString(); string text2 = comboBox2.SelectedItem.ToString(); richTextBox1.Text = String.Empty; richTextBox1.AppendText(text1); richTextBox1.Select(0, text1.Length); richTextBox1.SelectionColor = Color.Red; richTextBox1.AppendText(" "); richTextBox1.AppendText(text2); richTextBox1.Select(text1.Length + 1, text2.Length); richTextBox1.SelectionColor = Color.Green; }[/code] | |
Re: Yes, it's going to fall apart. By having just one connection to the database like this it's possible for multiple threads to place the connection in various states, interrupt threads that are trying to read/write the database, etc. Create a new connection for each thread. The way the .NET database … | |
Re: It's not C#, it's a mixture of C/C++ and C#. And to help you (maybe), show me a method that takes two parameters and returns the difference between the two. We'll convert this to a random number soon, just want to see if you know how to create methods. | |
Generating permutations of a sequence is a problem that is commonly asked. It's fairly easy to do if you know how many items will be used beforehand, but a generic method to do so would be better. The snippet will do a lazy generation of the permutations (the next one … | |
Re: [URL="http://msdn.microsoft.com/en-us/library/z50k9bft.aspx"]Array.Copy(Array, Int32, Array, Int32, Int32)[/URL] For example, if you want to copy 10 elements starting at the 23rd you'd use [code]string[] newArray = new String[10]; Array.Copy(myArray, 23, newArray, 0, 10);[/code] | |
Re: Take a look at [URL="http://gsraj.tripod.com/dotnet/reflection.html"]this[/URL] and [URL="http://msdn.microsoft.com/en-us/library/system.type.aspx"]this[/URL]. | |
Re: If the forms are identical with the same functionality, you can just create a new instance of the form. [code]Form1 form1 = new Form1(); Form1 form2 = new Form1();[/code] | |
Re: DateTime b = a.AddDays(-30) | |
Re: Them being interfaces has nothing to do with it. It's because of the way IEnumerables work and I'm not sure how I can explain it :) Change your arrays to List<> arrays and it should solve your problem. You'll probably have to add ToList() to the end of the LINQ … | |
Re: Do they use meaningful variable/method names? Do they comment code? Do you have a general idea what the code is trying to do? Reading others code is a skill you'll get better at with practice. Having partners who write clear code with meaningful names and comments helps (which they should … | |
Re: [code]class Program { public static void Main() { Console.Write("Enter the number of seconds: "); int seconds = int.Parse(Console.ReadLine()); TimeSpan fullTime = ConvertToHMS(seconds); Console.Write("Full-time is: {0}", fullTime); Console.ReadKey(); } public TimeSpan ConvertToHMS(int n) { return TimeSpan.FromSeconds(n); } }[/code] Not very useful but it is a subroutine. | |
Re: Panels have a PreviewKeyDown event you can attach to. That might help. | |
Re: [URL="http://msdn.microsoft.com/en-us/library/1009fa28.aspx"]Assembly.LoadFrom()[/URL] | |
Re: [URL="http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx"]List<T>[/URL] is a type of generic collection. When you create an instance of an a generic you have to specify what type of objects will be in the collection, thus the <int> in your example (meaning a List of int). | |
Re: You need some form of DNS service to resolve the IP address. If you can't run your own, there is a service called [URL="http://www.dyndns.com/services/dns/"]DynDNS[/URL] that specializes in resolving dynamic IP addresses. You just have to run their software on the machine with the dynamic IP and you are good to … | |
Re: * When the type of x is int or uint, the shift count is given by the low-order five bits of count. In other words, the shift count is computed from count & 0x1F. * When the type of x is long or ulong, the shift count is given by … | |
Re: I'm guessing the error is in line 80. What's the value of SingleLine, b and c when it gives you the error? | |
Re: [icode]StreamWriter.Flush();[/icode] | |
Re: [icode]dtr = dst.Rows[iPosact];[/icode] No . between Rows and [. You also don't need the new DataRow() part on the line above, you can combine the two lines into[code]DataRow dtr = dst.Rows[iPosact];[/code] | |
| |
Re: The DLL for WebCamCapture is in the bin/debug directory and this is a C# forum. | |
Re: Don't see a line in bold in there. | |
Re: Just FYI, your code has a bug in it. Any odd number that is the square of a prime will show as a prime. I've fixed that in the below code. [code]Boolean IsPrime(int n) { Boolean result = true; if (n == 1) { result = false; } else if … | |
Re: Line 43 - Shouldn't you be using insert or push_back to add an item to a vector? | |
Re: You could try using the [URL="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcolumn.dividerwidth.aspx"]DividerWidth[/URL] on the specific columns as it pads the right side of the column. Same property on the rows might get you something close to what you want. You'll have to get the column/row collection from the DataGridView and figure out which ones you want … | |
Re: For clarity. A lot of the typedefs help explain usage. DWORD tells you more than unsigned long as to what the intended usage is. | |
Re: If you don't use threads then all the work you want to do when you press Start will run on the GUI thread, which means the GUI won't update (you can't press buttons, etc.) while the work is being done. So you create a method that does all the work … | |
Re: Here is a sample program that will get you all the values that start with Date: [code]using System; using System.Collections.Generic; using System.IO; using System.Linq; namespace TestBed { class Program { static void Main(string[] args) { String[] lines = File.ReadAllLines("test.txt"); // Read all the lines into an array IEnumerable<String> date = … | |
Re: Since null isn't anything you can't call ToString() on it. You'll have to check for it: [code]npc_text.text1[0] = reader["text0_1"] == null ? String.Empty : reader["text0_1"].ToString();[/code] | |
Re: You need to explain more about what you mean by combination? Do you want every item in list 1 combined with an item in list 2? | |
Re: If you can read BNF [URL="http://msdn.microsoft.com/en-us/library/aa933118%28v=sql.80%29.aspx"]this[/URL] page has everything you need. | |
Re: Line 8 isn't needed. Use StringBuilder to build strings. Depending on the log size you could be creating thousands to millions of strings which will result in the Garbage Collector making frequent runs. |
The End.