Browsing 7239 questions and answers with Jon Skeet
Version 15.4.* of VS 2017 doesn't support C# 7.2. C# 7.2 support was introduced in VS 2017 version 15.5, which was released on December 4th. more 11/16/2017 11:36:38 AM
You could implement IComparable implicitly, yes. But fundamentally you want to try to discourage users from comparing a Note with anything other than another Note. You may have legacy usages if IComparable, but if anything knows about the... more 11/16/2017 10:23:55 AM
This is often done for optimization. It allows common operations (providing up to four values) to be performed without creating an array, whilst still giving the flexibility of allowing an arbitrary number of arguments. To give a... more 11/15/2017 9:26:46 AM
It's probably simplest to use the null-coalescing operator to "default" to the value that you're comparing against: if ((nullableEnumOne ?? regularEnumOne) == regularEnumOne && (nullableEnumTwo ?? regularEnumTwo) ==... more 11/8/2017 5:52:22 PM
Well you certainly don't need to use the query expressions - they're mostly just getting in the way. This code would be simpler as: XDocument doc = XDocument.Load(@"D:\MyFiles\test.xml",LoadOptions.PreserveWhitespace); var a =... more 11/7/2017 2:19:31 PM
If you're nervous that the compiler will optimize out the operator (although I doubt that it would ever do so) you could just call the Add method directly. Note that you don't need to add and then subtract - you can just add 0.000m. So for... more 11/5/2017 2:07:11 PM
I suspect the problem is that traffic on port 587 is blocked by default on Compute Engine, except for known IP addresses. From the firewall documentation: Compute Engine blocks or restricts traffic through all of the following... more 11/5/2017 8:30:49 AM
JSON doesn't distinguish between double and float. It doesn't even really distinguish between integers and non-integers - they're just numbers. But JsonTokenType.Float isn't really meant to indicate System.Single - it's "a floating point... more 11/1/2017 11:51:51 PM
To iterate over a stream element-by-element, just call the iterator() method: Iterator<String> iterator = stream.iterator(); while (iterator.hasNext()) { String element = iterator.next(); // Use element } It's not clear to... more 11/1/2017 8:01:39 PM
It removes zeros! Well yes, it would - you've specifically used .## which means "only include digits if they're significant". If you want to always have at least one decimal place, use DecimalFormat df = new... more 10/30/2017 8:52:38 AM