Browsing 7239 questions and answers with Jon Skeet
Yes, your assumption is accurate. If an object initializer just has: { Property = { ... } } rather than { Property = expression } then the setter for the property isn't used - the getter is used, and then either the Add... more 7/31/2017 7:38:26 AM
I'd just write a unit test that uses reflection. Something like: var duplicateGroups = typeof(SomeTypeInAssembly).GetTypes() .GroupBy(t => t.Name) .Where(g => g.Count() != 1); // Assert that duplicateGroups is... more 7/31/2017 7:07:34 AM
This happens in Eclipse if you've got your compiler settings to target very old source compatibility. With a compatibility level of 1.5 or above, it's fine - but if you set the source compatibility level to 1.3 or 1.4, you'll get this... more 7/29/2017 3:51:34 PM
The simplest approach is to convert this into a while loop, which just maintains state of "the current node we're testing". On each iteration of the loop, there are three possibilities: The current node has the right value, in which... more 7/28/2017 1:00:51 PM
You've got a single count variable, and your anonymous method captures it. That means when the delegate is executed, it will always use the current value of that variable. You want "the value of count when the delegate was created" which... more 7/28/2017 10:50:17 AM
Yes, this is called unboxing: Integer boxed = 10; // Boxing int unboxed = boxed; // Unboxing Boxing conversions are described in JLS 5.1.7; unboxing conversions are described in JLS 5.1.8. Note that if you try to unbox a null... more 7/28/2017 6:27:08 AM
Why can we not pass a char value as a argument to any method that accepts a short parameter Because there's no implicit conversion from char to short in an invocation context. whereas we can pass a char value to another method... more 7/27/2017 1:44:23 PM
For some reason, neither Array.Copy nor Buffer.BlockCopy is happy to copy from an int[] to a Foo[], although Array.Copy can go in the other direction perfectly happily. It looks to me like your options are: The kind of copy you showed... more 7/27/2017 8:43:52 AM
Of course I have installed System.ValueTuple as a nuget package I suspect that's the problem. My guess is that even though you're targeting .NET 4.5.2, you're running on a .NET 4.7 system, and that includes System.ValueTuple in... more 7/26/2017 7:30:09 PM
By calling ToString on an XElement, you're ending up with the whole element as a string, e.g. <Status>4</Status> ... and trying to parse that as an int. I would strongly suggest: Just using the Value property or a cast to... more 7/26/2017 4:10:41 PM