Browsing 7239 questions and answers with Jon Skeet
For two expressions, you can just use XOR: if (a == 1 ^ b == 0) For more than two, you could do something like: if (new[] { a == 1, b == 0, c == 2 }.Count(x => x) == 1) That basically counts all the "true" elements of the array... more 6/10/2016 10:16:23 PM
Yes, it's guaranteed to print out 0 due to a later bit of 18.6: A char* value produced by fixing a string instance always points to a null-terminated string. Within a fixed statement that obtains a pointer p to a string instance s, the... more 6/10/2016 10:11:14 PM
You're creating two separate instances of Test, and your incrementCount method is an instance method despite it incrementing a static variable. Each of your threads operates on a different instance of Test, so they won't block each other,... more 6/10/2016 3:37:51 PM
You can just use the overload of the DateTime constructor that takes a DateTimeZone: DateTime dtUtcTs = new DateTime(utcTs, DateTimeZone.UTC); Another option is to use a DateTimeFormatter so you can specify exactly the format you... more 6/10/2016 3:26:17 PM
Could there be some conversion or something that is happening that causes this problem? Yes. You're basically calling toString() on a byte array. That isn't going to do what you want. Did you look at the SQL you were executing? More... more 6/10/2016 2:16:39 PM
The problem is described in MSDN: "Mixed declarative code / imperative code bugs (LINQ to XML)": LINQ to XML contains various methods that allow you to modify an XML tree directly. You can add elements, delete elements, change the... more 6/10/2016 1:27:55 PM
I believe what is meant here is the "better betterness" rules which are documented in the Roslyn github repo. Sample code: using System; class Test { static void Foo(Action action) {} static void Foo(Func<int> func) {} ... more 6/10/2016 10:56:15 AM
The order of execution here is: Evaluation of i inside this(i) (i is still 5 at this point) Object constructor Instance initializer (the block that increments i from 5 to 6) Execution of the body of the InstanceBlocks(int) constructor... more 6/10/2016 10:36:16 AM
Looking at the IL code I tend to think that compiler creates only one instance of myLocalVariable. Nope. The C# language specification makes it clear that the variable is instantiated on each iteration of the loop - so there's a... more 6/9/2016 5:08:04 PM
In the CLR, there are two different types of array: Vectors, which are zero-based, single-dimensional arrays Arrays, which can have non-zero bases and multiple dimensions Your "array of arrays" is a "vector of vectors" in CLR... more 6/9/2016 5:51:56 AM