Browsing 7239 questions and answers with Jon Skeet
Well instead of relying on the default toString() implementation of HashMap, just loop over the entries: for (Map.Entry<String, Long> entry : nameSumMap.entrySet()) { System.out.println(entry.getKey() + ": $" +... more 7/8/2015 8:42:16 PM
You're trying to deserialize to a single form here: var forms = JsonConvert.DeserializeObject<Form>(Request.Params["formJson"]); Just change it to: var forms =... more 7/8/2015 1:24:35 PM
If you can, just put the ordering earlier, e.g. var states = SimulationPanel.innerPanel .Children .OfType<StateBar>() .Where(x => x.isSensorState()) .OrderBy(x => (decimal)(x.Margin.Left /... more 7/8/2015 8:50:12 AM
You can't, logically - a StreamReader is for text data, whereas protobuf data is binary data. It's not clear where you're getting the StreamReader from, but you should look for APIs designed for binary data instead. In practice, you may... more 7/8/2015 8:24:00 AM
As the error message says, you can't use the value of one instance field when initializing another. You probably don't want dir as a field anyway. Just move all of this into the body of the constructor... or ideally, only create your... more 7/8/2015 8:04:34 AM
The problem is that you're not trying to construct an instance of AgilityListener - you're trying to construct an instance of the anonymous inner class created in AgilityListener.startTimer. That's why the stack trace has: Caused by:... more 7/8/2015 5:30:11 AM
It sounds like you just want to use the safe navigation operator: def time = map.get('time')?.get('milliseconds') If map.get('time') returns a null reference, the result of the overall expression will be null, and get('milliseconds')... more 7/7/2015 7:17:10 PM
Firstly, it's worth being clear that your question doesn't actually involve expression trees at all - your lambda expression is just being converted into a delegate. Now, that lambda expression is this: (obj) =>... more 7/7/2015 2:07:33 PM
An async method never throws an exception directly. Instead, if an exception is raised within the body of the method, the task returned by the async method becomes faulted. The sleep isn't executed because the exception does prevent the... more 7/7/2015 1:21:37 PM
I would use Sum instead of Aggregate: decimal total = orderDetails.Sum(x => (decimal) (x.quantity * x.unitPrice)); Depending on exactly what your situation is, I can imagine this potentially working without any casts, or needing more... more 7/7/2015 1:18:54 PM