Browsing 7239 questions and answers with Jon Skeet
How frequently I need to update timezone database. When it changes :) You can find this out by fetching http://nodatime.org/tzdb/latest.txt which always contains the URL of the latest .nzd file. Or if you don't need automation,... more 7/27/2015 2:12:59 PM
Having two separate fields which will always have the same value seems like a really bad idea to me. You don't logically have two different pieces of state, so why have two separate fields? Instead, just use a local variable in write1 to... more 7/27/2015 9:51:37 AM
If you want to indicate that the date/time is invalid, use DateTime.TryParseExact to check whether or not it's valid, without throwing an exception. Use the return value (true/false) to determine the validity. Basically, you shouldn't... more 7/27/2015 6:53:09 AM
Basically, this would only be of any use to developers with flawed Equals implementations. From the documentation: The following statements must be true for all implementations of the Equals(Object) method. In the list, x, y, and z... more 7/27/2015 6:10:57 AM
You'd need to know the number of weeks in each year, so you could work out whether your condition was enabled for odd weeks or even weeks. You can't just work out whether this year or last year has an even or odd number of weeks in the... more 7/27/2015 5:51:22 AM
You shouldn't try to read more data than expected. Your loop should be: int n; int bytesLeft = fileSize; byte[] buffer = new byte[8192]; while (bytesLeft > 0) { int n = bis.read(buffer, 0, Math.min(buffer.length, bytesLeft)); ... more 7/26/2015 10:08:08 PM
I don't think you've understood what the argument to PropertyInfo.GetValue is meant to be - it's meant to be the target of the property fetch, whereas you're passing in the PropertyInfo itself. Additionally, your method only has one... more 7/26/2015 11:23:47 AM
Your Run method creates a new instance of Random(). I suspect you don't want to do that - after all, you've already got a property called MyRandom which you're populating when you create the array. Just take out the line: MyRandom = new... more 7/26/2015 8:44:46 AM
FirstOrDefault will return a null reference if no element is found - assuming the element type is a reference type. Instead of calling Equals on the result, just use ==... and don't call it twice: var first = bar.FirstOrDefault(c =>... more 7/26/2015 7:23:28 AM
Right, this is because the type is dynamic. That basically means the meaning of the float cast depends on the execution-time type of the value. The is operator is checking whether float and double are the same type - and they're not,... more 7/25/2015 9:20:02 PM