Browsing 7239 questions and answers with Jon Skeet
This line is the problem: string result = x.Result; When you use the Result property, that blocks the current thread until the task has completed. That's a problem when your continuations are meant to run on the same... more 6/5/2016 12:45:17 PM
Why it is necessary to having same return type for overriding a method? In once sense, "because that's what the language specification says". From the C# 5 specification section 10.6.4: A compile-time error occurs unless all of... more 6/5/2016 12:20:06 PM
You should specify the fully-qualified name as specified in the Class documentation. So in your case it would be: Class<?> clazzArray = Class.forName("[Landroid.graphics.FontFamily;"); The [ indicates an array, and then the L... more 6/5/2016 9:04:18 AM
Shuffle the list before you sort it. Collections.sort is guaranteed to be a stable sort, so equal elements will be in the same order that they were in the unsorted collection... you just need to make sure that that order is a suitably... more 6/4/2016 7:41:51 PM
Well, you can do it all in a single statement: var query = UnfilteredGrandadList.Select(grandad => new Grandad { Id = grandad.Id, // etc DadList = grandad.DadList.Select(dad => new Dad ... more 6/4/2016 4:54:47 PM
The Intersect extension method doesn't try to return a collection of the same kind as the inputs (e.g. a List<int>). It just returns a sequence implementing IEnumerable<T> for an appropriate T. So in your case you could... more 6/4/2016 2:54:08 PM
If you're trying to obtain the year, month and day of "now" in the Persian Calendar, you should use the Calendar class: using System; using System.Globalization; public class Test { static void Main() { var now =... more 6/4/2016 1:54:23 PM
The problem is that you're using Any with a negative condition - which means you'll include the value if there are any words that aren't included in the candidate. Instead, you want to think of it as: Exclude a file the words if any of... more 6/3/2016 7:26:08 AM
In Noda Time 1.x, use the LocalTime.TickOfDay property, and then just divide it by NodaConstants.TicksPerMillisecond to get milliseconds: LocalTime localTime = ...; long millis = localTime.TickOfDay / NodaConstants.TicksPerMillisecond; more 6/2/2016 2:10:08 PM
ToDictionary is your friend here. You can do it all in one statement: var query = xd .Descendants(ns + "element") .Single(element => (string) element.Attribute("name") == "getKeys") .Element(ns + "complexType") ... more 5/30/2016 7:29:00 AM