Browsing 7239 questions and answers with Jon Skeet
It's not really clear what you mean, but I suspect you just want to keep a reference to the "current node" - which you change when you get a new ID. So: TreeNode node = null; while ((line = reader.ReadLine()) != "end") { if... more 8/21/2014 9:26:16 AM
It's not really clear what you're trying to achieve, but if you just want to get the current time in a particular time zone, you can use: // No need to call Convert.ToString - it's already a string! string zoneId = "W. Australia Standard... more 8/21/2014 8:59:14 AM
If the package names are the same, the two classes are in the same package - it's as simple as that. The fact that they were built from different source directories is irrelevant - the only thing that identifies a package is its... more 8/21/2014 8:42:02 AM
Okay - the problem is actually in the array implementation of ICollection<T>.Contains. You can see that simply like this: static void Main(string[] args) { var ab = new MyEquatable("A", "B"); var target = new... more 8/21/2014 6:58:04 AM
The properties of an anonymous type are fixed at compile-time - you can't make them conditional. However, some other approaches you might want to think about: You could investigate whether a property is still included in the JSON... more 8/21/2014 6:40:03 AM
Why is everything getting cast to an int for comparisons? Because that's what the C# language defines. It doesn't define any operators on byte, short etc - they're all promoted to int before anything happens. That gets propagated to... more 8/20/2014 8:17:35 PM
I wouldn't use LINQ itself at all. I'd just use an XML API - probably LINQ to XML. Don't be fooled - the "LINQ" in the term really just means it's an API which is designed to work really well with LINQ to Objects. You don't need any... more 8/20/2014 8:08:13 PM
An ArrayList<ArrayList<Integer>> isn't a List<List<Integer>>, for the same reason that an ArrayList<Apple> isn't a List<Fruit>, and it's fairly easy to given an example of why that's the... more 8/20/2014 6:58:30 PM
If your only requirement is to get at the shl:Value element, then that's really easy with LINQ to XML - I wouldn't personally use XPath to do it: XNamespace shl = "http://www.shl.com"; XDocument doc = XDocument.Load(...); XElement element... more 8/20/2014 5:02:08 PM
Well if it's actually enumerable, presumably it implements IEnumerable... so you can just use: foreach (object item in (IEnumerable) MyList) { ... } You're not going to have a better compile-time type for item than object anyway... more 8/20/2014 4:48:30 PM