Browsing 7239 questions and answers with Jon Skeet
Isn't this wrong? why did the converted time increase by an hour on 1st November? Because that's when the clocks change, as you say. The problem is that "2015-11-01 01:49:00.000" is ambiguous in Pacific Time - it occurs twice, once... more 6/18/2015 7:55:02 AM
Your LINQ query can only ever have the same number of results as the number of partitions - you're just projecting each partition into a single result. If you don't care about the order, you just need to assemble the results of each... more 6/18/2015 6:21:11 AM
If you know the type in advance, I'd just use: var dictionary = list.Select(x => x.FirstName + ":" + x.UserId) .Concat(list.Select(x => x.LastName + ":" + x.UserId)) .ToDictionary(p => p,... more 6/18/2015 5:48:20 AM
Why are you constructing a new Magic instance within the loop (or trying to, anyway)? Surely you just need the ones in the set: for (Magic spell : spells) { spell.go(); } Note that currently you're ignoring the set variable in your... more 6/17/2015 9:30:39 PM
There are multiple options here, but I'd suggest the simplest thing is just to check each Grandchild: var grandchildren = doc .Descendants("Grandchild") .Where(x => (string) x.Parent.Parent.Attribute("name") == "Ken"... more 6/17/2015 8:13:19 PM
You can just call a method: private static readonly string _myString = GetMyStringValue(); private static string GetMyStringValue() { MyObject obj = new MyObject(); obj.someSetupHere(); return obj.ToString(); } You could do... more 6/17/2015 8:08:00 PM
You're telling BlockCopy to copy 3 bytes. You want Buffer.BlockCopy(src, 0, dst, 0, 24); or Buffer.BlockCopy(src, 0, dst, 0, 3 * sizeof(double)); ... in order to copy all 24 bytes. The fifth parameter of Buffer.BlockCopy is... more 6/17/2015 8:04:29 PM
The problem is that you're calling a method with a dynamic argument. That means it's bound dynamically, and the return type is deemed to be dynamic. All you need to do is not do that: object dObj = "123"; var obj = Convert(dObj); Then... more 6/17/2015 5:35:09 PM
Still I wonder, what are the benefits of lifting the delegate into a new class and caching it there over simply caching it at the call site? You've missed one other really important detail - it's now an instance method. I believe... more 6/17/2015 4:50:52 PM
This is the problem: toDecrypt = new byte[fis.available()+1]; Firstly, you're using the available() method, which is never a good idea. Next, even assuming it is returning the length of the file, you're adding 1 to it - why? You want... more 6/17/2015 4:37:41 PM