Browsing 7239 questions and answers with Jon Skeet
You can use the typeof operator with your known type and compare that with the dest type: if (dest == typeof(bool)) (Reference equality is fine here, as each type only has a single Type object representing it.) It's not clear what you... more 1/29/2015 10:55:50 AM
You've got at least two problems here: You're reopening the output file on each iteration. That's pretty much bound to be slow. Open it once at the same time you open the reader. You're not closing either the reader or the writer on... more 1/29/2015 10:32:42 AM
One obvious option is to keep a Long instead of a long wherever you're using this. Then you can just use a null reference for "no associated thread". That's a good general approach to this problem. However, in the specific case of... more 1/29/2015 9:38:17 AM
Currently you can't instantiate a Cow - because doing so will create an Animal, which will in turn try to populate it map with another Cow etc. (In fact you can't create any Animal instances for the same reason.) It sounds like your map... more 1/29/2015 9:33:54 AM
You're currently inconsistent about whether max is an inclusive lower bound, as suggested here: int max = list.size()-1; ... max = mid - 1; or an exclusive lower bound, as suggested here: while (max > min) You can make it work... more 1/28/2015 10:15:08 PM
There's basically no such concept. After all, 365 days isn't 1 year if you start in a leap year. What you could do is take some "base" date, add your days-based period to that, and then take a year/month/day based period from the... more 1/28/2015 1:50:06 PM
Why does compiler won't break when I don't specify keyword. To avoid the "brittle base class" problem - where Cat originally has the Say() method, and then the author of Animal wants to add a Say() method too. With the current... more 1/28/2015 1:17:24 PM
I suspect you're looking for TaskCompletionSource<TResult>. Basically, you create one of those (and remember it), and hand back the task that it provides in the Task property. When the event is triggered, set the appropriate... more 1/28/2015 12:44:43 PM
I strongly suspect the problem is that you're trying to access this (implicitly) within a field initializer. You're not allowed to do that. Just move the initialization into a constructor: // You don't really use public fields, do... more 1/28/2015 11:17:47 AM
Given that you have a local time and an offset, I'd suggest representing that in DateTimeOffset. So: DateTime localTime = DateTime.ParseExact(...); DateTimeOffset offsetTime = new DateTimeOffset(localTime, offset); Then you still know... more 1/28/2015 10:36:57 AM