Browsing 7239 questions and answers with Jon Skeet
Basically, no - there's nothing to let you use automatically implemented properties with "just a bit" of custom code. You could shorten your code, though to: public Animator Animator { get { return _anim ?? (_anim =... more 8/23/2015 7:07:25 PM
Between two local date/time values, there will always be 24 hours. It sounds like you're interested in a date in a particular zone, in which case you want: var startOfDay = zone.AtStartOfDay(date); var startOfNextDay =... more 8/22/2015 8:29:41 AM
To fetch the time zone IDs programmatically, use the Ids property in IDateTimeZoneProvider. For example, to find all zones: var provider = DateTimeZoneProviders.Tzdb; foreach (var id in provider.Ids) { var zone = provider[id]; //... more 8/22/2015 8:23:23 AM
Don't take this approach at all. You should be writing to a binary stream of some description - and write the binary data for the length of the packet/message, followed by the message itself. For example: BinaryWriter writer = new... more 8/19/2015 6:48:16 PM
So it is closed using a non-existing type of name "T" and only doing GetGenericTypeArgument on it makes it open again. Why is that? Because there is one type argument provided - the type parameter to B. Look at how you're specifying... more 8/19/2015 9:27:15 AM
You probably want to keep the value part as it is - or ideally as yyyyMMdd, as two-digit year formats are horrible - and just format the display part differently. I don't think there's anything to use two-letter month abbreviations - the... more 8/18/2015 8:29:51 AM
If you construct the TreeMap specifying a comparator, then that will be used to compare the keys. If you construct the TreeMap without specifying a comparator, then the keys must implement Comparable. Typically the key would implement... more 8/15/2015 12:02:34 PM
There are a few differences, yes. The first one won't box value types - but will end up JIT-compiling the method multiple times for different type arguments (once for all reference types, and once per value type). So: byte x1 = 10; int... more 8/15/2015 10:28:13 AM
I would suggest avoid using a ref parameter for this in the first place - it seems needlessly complicated to me. I'd rewrite DoAction as: static string DoAction(string data, Action<string> action) { data = data == null ?... more 8/15/2015 10:20:07 AM
however it blocks SOME thread, where the awaited task gets shifted to? It depends on what you mean by "block". It doesn't cause any thread to go to sleep for 1 second, or (worse) spin wait for the delay to complete. Instead, it... more 8/15/2015 10:15:40 AM