407 Posted Topics
Re: This looks like VB.NET, not C#. In either case, neither directly inherits from the other; therefore, you can't cast between the two types. The do however, share a base class: `System.Data.Common.DbConnection`. You could, possibly, work with a DbConnection class directly. If there are specific functions implemented by the `SqlConnection` or … | |
Re: You can always give [LINQ to XML](http://msdn.microsoft.com/en-us/library/bb387098(v=vs.100).aspx) a try. Another options is to read the XML file with the [System.Xml.Linq.XDocument.Load()](http://msdn.microsoft.com/en-us/library/bb358684(v=vs.100).aspx) or [System.Xml.XmlDocument.Load()](http://msdn.microsoft.com/en-us/library/w009fhk7(v=vs.100).aspx) method, locate the User node, and iterate through each of the Attempts nodes (checking dates and adding the Distance, Duration and number of nodes per Place). Give it … | |
Re: What do you mean by unknown errors? Are you getting an exception, or is it giving you unexpected results? Give some more detail. Also, an example of your test input. | |
Re: Any numeric literal preceeded by 0x indicates a [hexadecimal](http://en.wikipedia.org/wiki/Hexadecimal) (or base-16) value. Basically each digit represents a value from 0-15 (0-9 then A-F). It is useful because two hexidecimal digits represent exactly one byte (00, 01, ... fe, ff in hexadecimal is equivalent to 0, 1, ..., 254, 255 in … | |
Re: Take a look at the [DateTime](http://msdn.microsoft.com/en-us/library/system.datetime.aspx) struct. .NET does not have a class/struct that only represents a date, so it'll use a DateTime with the time set to midnight. So you can use [ToShortDateString()](http://msdn.microsoft.com/en-us/library/system.datetime.toshortdatestring.aspx), [ToLongDateString()](http://msdn.microsoft.com/en-us/library/system.datetime.tolongdatestring.aspx) or [ToString(String)](http://msdn.microsoft.com/en-us/library/zdtaw1bw.aspx). | |
| |
Re: Queue's are not thread safe, so you should be using locks. Pretty sure I gave you an example in a previous [post](http://www.daniweb.com/software-development/csharp/threads/434677/active-pipe-filter-in-c#post1867754). Was there anything about it you didn't understand? | |
Re: You end a Thread by returning from the method specified in the Thread constructor. | |
Re: > take it up with the authorities at your school or college I hope your joking. The last thing most people need in school, is a professor with a chip on their shoulder. | |
Re: I think you have it backwards... The string should be the key in this case (i.e. `SortedDictionary<string, int>`), since there is a one-to-many relationship between the key and the value. If you did it with `SortedDictionary<int, string>` you could never have words that equal the same amount. | |
Re: You're comparing to variables `empName` and `Quit`. I don't see a variable called `Quit` declared anywhere. If you wanted to compare it to the string "Quit", then it would look like this: if (empName != "Quit") { ... } Note that it is case-sensitive. If you want to ignore case, … | |
Re: Are you getting an exception? That would be helpful to have. At a quick glance, try adding the row `oDetailRow` to the table before calling `SetParentRow()`. | |
Re: Did you try: Something<K, V>[] s = new Something<K, V>[size]; That's assuming the other class is generic, and has K and V defined. If not, you need to explicitly declare it, like so: Something<string, int>[] s = new Something<string, int>[size]; | |
Re: There's also the `Leave` event; it's fired when the TextBox loses focus. Just keep in mind, that if you have an `AcceptButton` set and the user presses <Enter>, the `Button.Click` event will fire, but the `Leave` event will not (since it never really loses focus). You may want to even … | |
Re: You'll have to poke around the registry for that. You can use [RegistryKey.OpenRemoteBaseKey](http://msdn.microsoft.com/en-us/library/dd411618(v=vs.100).aspx) to access a remote registry. There are some conditions to using it; they are discussed in the provided link. There could be some security risks with this however. You could also install a client application/service on the … | |
Re: C# doesn't work this way. `using` is only intended to have the compiler imply the namespace of a class. IMO, this would make your code difficult to read, as another programmer would have to search for the particular class the method is defined in. | |
Re: See [here](http://msdn.microsoft.com/en-us/library/ms366768(v=vs.100).aspx). Basically, you subscribe to an event like so: comboBox.SelectedIndexChanged += comboBox_SelectedIndexChanged; and you can unsubscribe from an event like so: comboBox.SelectedIndexChanged -= comboBox_SelectedIndexChanged; | |
Re: > Is this where RunSQL() should go? Yup. > How does it determine if the progress has changed? You use the `BackgroundWorker.ReportProgress()` method; that is, you explicitly update progress if you wish. You can get the instance of the `BackgroundWorker` by using the `sender` parameter. It is important to note … | |
Re: You could do it in the constructor: public class Customer { private readonly string Name; private readonly string Phone; private string Number; public Customer(string name, string phone) { if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name"); Name = name; ... } } FYI, the purpose of `readonly` is to prevent the value from … | |
Re: This seems very similar to your [last post](http://www.daniweb.com/software-development/csharp/threads/434428/read-from-txt-file-using-threads). In either case, show your code, and explain how you want it broken up. | |
Re: > Sorry about that.. here's the code.. You're code is still wrong, the OP said nothing about restricting symbols... Please stop, a quick, clean, readable and correct solution has already been offered; your solutions offer very little of that. | |
Re: Ok, a few things: 1. When calling a function, you do not need to define the type of the parameters. For insatnce, on line 42, you would use `PlayGuess(solution);`. 2. On line 65, you try to declare a variable called MAXGUESSES. This is alreay defined on line 3. The compiler … | |
Re: That's a good start, but I wouldn't think it would be enough (FYI, I'm more of an application developer and never interned). Client-side scripting (JavaScript) is still extensively used; however, many sites are using server-side scripting as well these days (e.g. PHP, ASP or ASP.NET). Also, AJAX really helped push … | |
Re: A struct wouldn't save any "memory", it would pretty well be equivalent. Depending on the architecture of your system and how the compiler wants to handle it, all data in a struct would be passed on the stack, so it would probably be better to use a class. A class … | |
Re: Take a look at the [MSDN article](http://msdn.microsoft.com/en-us/library/fk6t46tz(v=vs.100).aspx). And try this out: Sub Main() Try Try Console.WriteLine("Try") Throw New Exception("Try") Catch Console.WriteLine("Catch") Throw New Exception("Catch") Finally Console.WriteLine("Finally") End Try Catch ex As Exception Console.WriteLine("Exception: " & ex.Message) End Try Console.ReadKey(True) End Sub You get the following output: Try Catch Finally Exception: … | |
Re: You are "printing" to two separate PrintStream objects (out and err). In your case, they both output to the same place (i.e. the console, or your IDE's output); however, they both use internal buffers that are dependant on the object. This is the same way files tend to work: data … | |
Re: > 1 this takes as input any number right? Not quite, it takes a set of numbers. The while, indicates a loop that repeats as long as "read was successful". It's difficult to determine from the way your post is tabbed, but it probably loops after the "read number" statement. … | |
Re: You initializes one dimension of the 2D array. You need to initialize each element of that dimension, like so: TControls[t] = new Control[size]; This is called a jagged array, since each element of the first dimension can have a different length. FYI, C# also has a convention for a rectangular … | |
Re: It's exactly what the title of your post says it is. You need to give the SelectCommand property a command. Hint: SqlDataAdapter (adapter) has a SelectCommand property and you initialized an SqlCommand class (sqlCmd). | |
Re: If you're specifically targeting Windows, you can use Visual Studio Express. If you want to support Mac and Linux as well, you'll probably want to go with MonoDevelop. There are a lot of IDE's out there, just Google it, same goes for quick tutorials on creating desktop applications. | |
Re: Hmm, that's interesting... When textBox1 loses focus, are you giving it to textBox2? I would imagine (but never tried it) that when a TextBox gains focus it would reevaluate the property. I'm on my cell, so i can't test anything at the moment. As for number 3 the handling of … | |
Re: In what way does it crash? Is there an exception you are getting? I was able to run the program without it crashing. C# can, of course, open any type of file, it's just a bunch of bytes... Also, might I recommend you avoid using `var` that heavily. It has … | |
Re: Hmmm, sounds like homework to me... Read the rules, and show some work before expecting any help. | |
Re: First, you should be using the MdiChildren property, not OpenForms, and the event is not going to fire at the appropriate times (mainly on closing) for your purposes. I could go deeper into it, but I'd rather recommend you not add anything to an MDI container except MDI child forms … | |
Re: Are you using Windows XP 64-bit or Windows Vista 64-bit? It doesn't work for either one of them. Also, it uses the PC speaker, not the sound card, which could be disabled via the BIOS or a jumper on the motherboard. Try opening of the command prompt, type Ctrl+G and … | |
Re: You'll have to set the `gdiCharSet` in the `Font` constructor (or in the properties panel if you're using Visual Studio). Through some testing, it looks like 128, 129, 130, 134 and 136 work (I was testing with यह परीक्षण है।, which should be Hindi according to an online translator...). You … | |
Re: You'll need to add an explicit refrence to it in the XAML, kind of like `using namespace ... ;`. The MSDN has some documentation on this [here](http://msdn.microsoft.com/en-us/library/ms747086.aspx). Basically, you add it to the root element it like so: <Page ... xmlns:tk="clr-namespace:Silverlight.Windows.Controls.Toolkit;assembly=<assembly_name>" ... /> Where you'd replace <assembly_name> with the actual … | |
Re: Could you just use a line like: `runningcount[city]++;`? Quick test: Dictionary<object, int> runningcount = new Dictionary<object, int>(); object city = new object(); runningcount.Add(city, 3); Console.WriteLine(runningcount[city]); runningcount[city]++; Console.WriteLine(runningcount[city]); Console.ReadKey(true); This program outputs: 3 4 The indexer property can also be set, which allows you to change the value. Unless there is … | |
Re: You convert guess to upper-case on line 77, and compare it to the "gameWord" on line 88, which is all lower-case. There's a few other things with your code that you should fix as well: 1. You initialize `boolArray` twice (line 16 and 22). 2. All elements of an array, … | |
Re: You'll probably have to use COM with Word, aka Word Interop; here's the [reference](http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word(v=office.11).aspx). Note that this requires particular versions of Word to be installed on the client machines. I'm sure there are ways to determine and utilize the version at runtime, although I've never had the need to look … | |
Re: For something like this you may have to look at the PDF specification. There's also an Acrobat SDK and PDF Library SDK, both of which cost money, and I have no idea what they offer in terms of detecting corruption. From what I understand, 1.7 is the latest specification, although … | |
Re: It won't ever evaluate to false, but the break statement would handle this. The `matches()` method actually uses regular expressions, which is overkill in this situation. Did you use all caps, because the regex engine in case-sensitive by default? In either case, I would recommend using `inputName.equals()` or `inputName.equalsIgnoreCase()` instead … | |
Re: Did you assign a OleDbCommand to the OleDbDataAdapter's SelectCommand property? The command builder uses the SELECT query to construct other queries, such as the INSERT INTO query. | |
Re: Is this a personal or business plan through your ISP? In either case, you may want to look over your service agreement, as some prohibit users from setting up servers. Whether they monitor and enforce it, I have no idea. | |
Re: @nesa24casa He said he can't use classes. Structs are essentially the same thing (minus the allocation on the heap), so I doubt he could use them. I ran a quick test with: string[] ret = RazvrstiPoVrsti("c:\\test.txt"); Console.WriteLine(ret.Length); for (int i = 0; i < ret.Length; i++) Console.WriteLine(ret[i]); Console.ReadKey(true); and it … | |
Re: What have you tried? [String.Substring()](http://msdn.microsoft.com/en-us/library/system.string.substring(v=vs.100).aspx) and [Double.Parse()](http://msdn.microsoft.com/en-us/library/system.double.parse(v=vs.100).aspx) are probably good places to start. |
The End.