Browsing 7239 questions and answers with Jon Skeet
The whole point of the comparison is to say whether one item is greater than, less than or equal to another. A set doesn't allow equal values - and in a sorted set, equality is defined by the comparison. It's as simple as that. For your... more 2/19/2016 6:10:26 PM
This is because you've declared your variable to be of type UserControl. That means the compiler will only let you use members declared in UserControl and the classes it inherits from. The actual object is still of type usercontrol1 at... more 2/19/2016 5:32:30 PM
Why does the soft cast not use the implicit converter? Well, that's the way the language is specified, basically. From the C# 5 specification section 7.10.11: If the compile-time type of E is not dynamic, the operation E as T... more 2/19/2016 2:53:58 PM
Here's a simpler approach, removing the BOM after decoding: // Your data is always in UTF-8 apparently, so just rely on that. string text = Encoding.UTF8.GetString(data); if (text.StartsWith("\ufeff")) { text =... more 2/19/2016 2:47:50 PM
I see various problems at the moment: Parallel.For is just starting the tasks. It won't wait for them to complete. It will wait for the DoSomething method calls to return, but they're returning tasks representing the asynchronous... more 2/19/2016 7:16:23 AM
It's not freezing weirdly at all - it's freezing entirely reasonably. You're calling task.Wait(), which stops your UI thread from doing any more work until that task has completed. However, that task itself needs to get back to the UI... more 2/19/2016 7:10:51 AM
Both call the binary operator. The unary operator would be called if you only had one operand: v3 = +v1; The unary + operator is rarely useful, to be honest - but it's mostly there for symmetry with the unary - operator. more 2/18/2016 9:22:34 PM
You just need to specify the type of the null value in your anonymous type initializer: .DefaultIfEmpty(new { x.Code, x.Desc, Value = (decimal?) null })) When you used 0, you were creating a separate anonymous type that had a Value... more 2/18/2016 1:29:49 PM
The first uses the new-to-C#-6 expression-bodied member syntax. It's equivalent to: public object MyObject { get { return new object(); } } The second is also new to C# 6 - an automatically implemented read-only property. It's... more 2/18/2016 1:12:27 PM
Is there a code way to tell it to shut up and mind its own business? The compiler's business is implementing the C# specification. The code you've written should not compile according to the C# specification. The s.DoSomething() call... more 2/18/2016 1:08:14 PM