Browsing 7239 questions and answers with Jon Skeet
Just cast: intVal = (int?) dblVal; This will already result in a null value if dblVal is null. Note that unlike Convert.ToInt32(double), this does not result in an exception if dblVal is outside the range of int. If that's a concern,... more 10/7/2015 6:06:57 PM
There are two things wrong here: You're assuming that the second entry you added to D2 is the one retrieved by D2.ElementAt(1). Don't make that assumption: dictionaries are basically unordered. You're calling an extension method... more 10/7/2015 4:37:37 PM
Assuming you've got a separate test project, yes that's really just another class library project. (If you're expecting VS to split classes from a single project into "test" and "non-test" assemblies, then the answer is no... and you... more 10/7/2015 2:49:03 PM
Firstly, it's not clear why you're calling ToList all over the place. At the end, maybe... but no need for it any earlier. I think you're probably looking for the Any method: List<Condition> cod = MyRules.Where(r =>... more 10/7/2015 2:25:36 PM
You shouldn't try to get everything down to one line - just as brief as is readable. In this case, you can use: foreach (var project in MyProjects.Projects.Where(p => p.Name == "Overhead")) { project.IsActive = true; } That's... more 10/7/2015 1:34:07 PM
The problem is that XmlNodeList only implements IEnumerable, not IEnumerable<T>. The simplest way to use LINQ on it is to call Cast: var query = nodeList.Cast<XmlNode>() .Where(...) ... more 10/7/2015 9:59:19 AM
Well you're passing the whole of "-X... -D... -cp ... Main" as a single argument. Instead, you should have: Process p = Runtime.getRuntime().exec(new string[] { "cmd.exe", "/c", "javaw.exe", "-X...", "-D...", "-cp", "...", "Main",... more 10/7/2015 9:46:38 AM
d1 and d2 are clearly different, so their formats shouldn't be same Well they wouldn't be if you had an unambiguous format - but you don't. (Heck, even leaving time zones aside you're only formatting to the hour, so it's trivial to... more 10/7/2015 9:14:36 AM
Presumably your server isn't closing the connection - therefore the underlying stream for the reader isn't closed... at any point the server could send more information. readLine() only returns null when the stream has been closed, i.e.... more 10/7/2015 7:59:20 AM
(Caveat: I've never used Nancy. This is just a matter of looking at the history in Github.) It looks like the + operator signature you're using changed from this in 1.2.0: public static ErrorPipeline operator + (ErrorPipeline... more 10/6/2015 9:54:02 PM