Browsing 7239 questions and answers with Jon Skeet
This is like jdweng's answer, but slightly simpler and it won't throw an exception for missing item IDs: var hitCountsById = HitCountItemIDS.ToDictionary(x => x.ItemID, x => x.HitCount); foreach (var item in parsedMerchantData) { ... more 2/20/2017 7:01:32 PM
I'm surprised it's working on the first iteration - because you're not checking a useful file. Instead of calling Path.Combine with multiple arguments, you're concatenating TaskData.xml with the current directory. You want: if... more 2/20/2017 6:09:47 PM
This does indeed seem to be a use case we hadn't considered. For "normal" usage, sealing NodaPatternConverter feels like the right approach - but when a JsonConverter has to be specified by type rather than instantiated, the sealing is... more 2/20/2017 6:02:50 PM
addLast doesn't somehow maintain a notion of "this should be last" forever - it just adds to the end of the current dequeue. It's equivalent to add, as documented. So if we look at the values at each step, we have: deque.add(20); //... more 2/19/2017 9:37:59 AM
It's nasty, and it's not guaranteed to work (it depends on implementation details) - but this works for me... it basically provokes the state machine to pass a continuation to an awaiter. We can then get the state machine out of the... more 2/17/2017 2:57:44 PM
It's specifying a property when creating an instance of the attribute. Attributes can have constructor parameters and properties - this one is setting a property. Note that you can mix positional constructor arguments, named constructor... more 2/17/2017 12:06:30 PM
No, there's no way of doing that. Default parameters have to have constant values - they can't depend on a value taken from a local variable. It sounds like you should probably construct an instance which stores a driver reference in a... more 2/17/2017 11:58:08 AM
Whats wrong with this code. You're using text-based classes for binary data. Is it possible with BufferedReader and Writer Class? Not while you're dealing with binary data, no. I know how to to make copy of image using... more 2/16/2017 3:57:55 PM
You don't need MoreLINQ to demonstrate this at all - and you can simplify the sample code, too: using System; using System.Linq; using System.Xml.Linq; class Program { static void Main() { var element = new XElement( ... more 2/16/2017 9:15:54 AM
Basically, you just need to cast - the language rules don't allow the compiler to take the if statement into account when it thinks about the types involved. Note that you also need to call ToList<Entry>(), specifying the type... more 2/15/2017 3:18:47 PM