Browsing 7239 questions and answers with Jon Skeet
Firstly, you should add diagnostics to print out the actual data rather than just knowing that it's "right" or "wrong". Next, the actual problem is that you're ignoring the result of udp_sock.ReceiveFrom. That will tell you how many bytes... more 9/28/2013 6:09:01 AM
I think you're just looking for: if (task != null && !task.IsCompleted) As documented, IsCompleted covers faulted and canceled states as well as RanToCompletion: IsCompleted will return true when the task is in one of the... more 9/28/2013 6:01:44 AM
I think you've misunderstood what Monitor::Enter does. It's only a cooperative lock - and as wralot doesn't try to obtain the lock at all, the actions of setalot don't affect it. It's not really clear why you expected to get a constant... more 9/28/2013 5:51:31 AM
The "FM" in this case is the Java Language Specification. You want section 6.6.1 which includes: Otherwise, if the member or constructor is declared private, then access is permitted if and only if it occurs within the body of the top... more 9/27/2013 10:07:36 PM
This is a problem using automatically implemented properties in structs. You need to explicitly chain to the parameterless constructor: public Rectangle(int x, int y, int width, int height) : this() { X = x; Y = y; Width =... more 9/27/2013 9:31:12 PM
I'm assuming you don't want to make the type itself check for equality and override ToString? Because that would do it nice. One option would be to use anonymous types to accomplish the same goal: Assert.AreEqual(new { X = testX, Y =... more 9/27/2013 9:28:18 PM
This is already implemented for you, with the Array.IndexOf method: int index = Array.IndexOf(array, name); Or use the fact that an array implements IList<T>, and use IList<T>.IndexOf: // IndexOf is implemented... more 9/27/2013 8:46:50 PM
You want Type.MakeGenericType and then Activator.CreateInstance... but then calling a method on the newly-created object will be tricky. Ideally you could have a non-generic base class or interface containing those members: public... more 9/27/2013 8:14:32 PM
It's all down to NumberFormatInfo.CurrencyNegativePattern. Presumably you've got the value 0, when it sounds like you want 1. It's not clear whether you're currently using the user's CultureInfo, the server's one, or something else. But... more 9/27/2013 7:50:17 PM
I think you're just missing section 12.4.2 of the JLS, which includes: Next, execute either the class variable initializers and static initializers of the class, or the field initializers of the interface, in textual order, as though... more 9/27/2013 7:39:42 PM