Browsing 7239 questions and answers with Jon Skeet
They're exactly the same thing, as is new int?(). If you're just assigning a variable, you normally wouldn't need it at all though. I'd just use: int? x = null; for example. The time I most often need one of these expressions is the... more 11/4/2016 5:31:30 PM
(I'm assuming we're only talking about LINQ to Objects.) It's still deferred in that until you start asking for results, it won't read the source collection at all. But yes, once you ask for the first result, it will indeed read the whole... more 11/4/2016 3:49:59 PM
I suspect you should make selected a list of IDs... then you can just use Contains: public ActionResult TransferDevices(IList<XXXViewModel> viewModel) { var selected = viewModel.Where(x => x.isSelected) ... more 11/4/2016 9:29:42 AM
Your first piece of code is using a collection initializer, which doesn't use logical assignment, but instead is intended to call Add on an existing collection. In other words, this: var x = new Dictionary<string, List<int>>... more 11/3/2016 9:31:57 AM
The method logically still exists, and could be called by reflection, for example. The C# 5 specification only talks about the calls being omitted - nothing about the implementation being omitted (section 17.4.2): A method decorated... more 11/3/2016 9:29:15 AM
The problem is more simply demonstrated like this: import java.io.*; class Test { private static Reader reader = new FileReader("foo.txt"); } The problem is that the static initializer for your class can throw an exception. That's... more 11/3/2016 7:54:17 AM
You're using XmlDocument.Load, which is meant to accept a URL. I believe you meant to use XmlDocument.LoadXml which parses the text as XML. (As an aside, I'd strongly recommend updating to use XDocument if you possibly can. LINQ to XML is... more 11/3/2016 7:44:07 AM
If you look at .L1 and .L2, the JIT compiler has just decided to reverse the order - it's put the else code first, and reversed the condition. The jle is "jump if less than or equal" so it's become the equivalent of the C#: if (a[idx]... more 11/2/2016 6:40:19 PM
I would like any new entry with either the same weight or term as previously added entries to be considered a duplicate. That's not how equality works. Equality has to be transitive - so if x.equals(y) returns true, and y.equals(z)... more 11/2/2016 2:17:58 PM
Noda Time 1.x only targets PCLs. You may be able to get it to work with netcoreapp1.0, but I'm not going to guarantee it. But Noda Time 2.0 targets netstandard1.1, so should be fine. That's only available as an alpha release right now,... more 10/31/2016 6:12:36 PM