Browsing 7239 questions and answers with Jon Skeet
Yes, it's well defined that it will call the Double overload. It couldn't call the Integer overload because there's no implicit conversion from double (which is the type of the conditional expression) to Integer. Basically, there are two... more 4/19/2017 3:35:29 PM
Well it sounds like you don't want to use Skip in this case. Just use a local variable to remember whether this is the first iteration or not. bool firstItem = true; foreach(var item in items.Where(x => x.SomeCondition)) { ... more 4/18/2017 1:51:58 PM
If decimal.MinValue were only declared as a static readonly field, you wouldn't be able to use it as a compile-time constant elsewhere - e.g. for things like the default value of optional parameters. I suppose the BCL team could provide... more 4/17/2017 8:44:04 AM
I would suggest using java.time.MonthDay to represent each value involved. You then need to consider two alternative situations: from is before or equal to until, in which case you need to perform a test of from <= current &&... more 4/14/2017 11:03:56 AM
In Java, you'd use BigDecimal. That's not quite the same type, but it's reasonably close. You just need to reconstruct the 96-bit integer as a BigInteger, then scale it and optionally negate it: import java.math.BigDecimal; import... more 4/12/2017 3:01:11 PM
I suspect the problem is that the test method is generic. Instead of using the generic Assert.Throws<T>, use the overload that accepts an exception type: [TestCase(null, typeof(ArgumentNullException))] [TestCase("",... more 4/12/2017 9:46:40 AM
No, there's nothing like this. It would be fine if you were trying to throw an exception - and indeed I have a bunch of Precondition.CheckXyz methods that do exactly that sort of thing - but there's no "conditional return statement" which... more 4/12/2017 7:41:26 AM
The problem is that you're trying to read binary data as if it's text. Don't use the ReadExisting() call - use Read(byte[], int, int): public void HandleDataReceived(object sender, SerialDataReceivedEventArgs e) { byte[] data... more 4/12/2017 7:40:20 AM
This: public LabelImage(LabelImage source) { Label = source.Label; image = new MagickImage(source.image); fileinfo = source.fileinfo; } Is implicitly this: public LabelImage(LabelImage source) : base() { Label =... more 4/11/2017 5:58:58 PM
Fundamentally, you're using the wrong approach - if you want to convert to UTC, use TimeZoneInfo.ConvertTimeToUtc(DateTime, TimeZoneInfo). You'll want to be careful around times that are either invalid (because they were skipped) or... more 4/11/2017 5:52:41 PM