Browsing 7239 questions and answers with Jon Skeet
Destructors (or finalizers) are good to have in the language - but you should almost never use them. Basically you should only need them if you have a direct handle on an unmanaged resource, and not only is that incredibly rare, but using... more 4/12/2014 6:23:37 AM
A few options spring to mind: Write a method in whatever class this is which knows about both the status and the color: // Implicitly sets color to red. Consider using an enum for statuses screen[0][1].setStatus(1); Write a method... more 4/12/2014 6:19:03 AM
You can't cleanly do this with normal LINQ, as far as I'm aware. The streaming operators within LINQ rely on you being able to make a decision about an item (e.g. whether or not to filter it, how to project it, how to group it) based on... more 4/11/2014 10:45:56 PM
Two potential problems... Firstly, it's possible that this: <exec executable="java\bin\javac"> ... is making Ant look for a file called java\bin\javac within the directory c:\workspace\myworkspace, where it doesn't exist. It's... more 4/11/2014 10:27:54 PM
Why is it not needed for a Java application to follow the Java naming conventions? Because they're conventions rather than rules. It would be very odd for naming conventions to be enshrined in a language specification as actual rules... more 4/11/2014 6:51:57 PM
Well the error message seems reasonably clear - GetUserDetails is returning XElement (from LINQ to XML) rather than XmlDocument (from the older API). This shouldn't be a problem though, as basically you just need to select an element and... more 4/11/2014 12:53:58 PM
Your pseudo-code is quite confusing, but I suspect you want something like: List<Item> items = ...; List<int> selectedIds = ...; foreach (var item in items.Where(x => !selectedIds.Contains(x.Id))) { item.Quantity = 0;... more 4/11/2014 10:07:04 AM
There's no "one size fits all" answer here because there are different reasons for declaring variables. Static variables (declared directly within the class, with the static modifier) are class-wide, rather than specific to a single... more 4/11/2014 8:25:02 AM
If you just need the category names, you need to project from the list of galleries to a sequence of category names - and then Distinct will work: // Variable name changed to match C# conventions List<Gallery> galleryList =... more 4/11/2014 6:16:16 AM
The first thing to do is to stop constructing your SQL like that. If you really need to pick the table dynamically, you should make sure you use a whitelist of valid ones... but for the "where" clause you should use parameterized SQL -... more 4/11/2014 2:14:20 AM