Browsing 7239 questions and answers with Jon Skeet
Instead of using ObjectOutputStream, you should create an OutputStreamWriter, then use that to write the JSON text to the stream. You need to choose an encoding - I would suggest UTF-8. So for example: JSONObject json = new... more 2/22/2014 12:09:06 PM
You don't get to the return statement in 1 second. The method returns a Task<ActionResult> as soon as it reaches the first await expression which hasn't already completed. That task will not be completed (so you can't get its result)... more 2/22/2014 8:40:24 AM
Well, you could explicitly use ContinueWith - or you could break off each "get and save" into a separate async method or async lambda. For example: async Task GetAndSaveRedAsync(SomeThing thing, SomeRepository rep) { var red = await... more 2/22/2014 8:21:17 AM
Why would HttpServlet not be abstract? An instance of just HttpServlet would be useless - the whole point of a servlet is to be able to provide useful responses to requests, and HttpServlet can't do that. It's generally a good idea to... more 2/21/2014 5:34:03 PM
but could someone explain me why Sure - arrays don't override equals, therefore they inherit the behaviour from Object, where any two distinct objects are non-equal. It's even simpler than the version you showed if you use a... more 2/21/2014 1:45:08 PM
You're not starting the task - so it will never finish. Use Task.Run instead of new Task and it will create and start the task for you. Note that you're still reading the file synchronously, which isn't ideal... and if your Subject... more 2/21/2014 12:27:04 PM
I would simplify it to: Work out the lower bound, which must be at least 0 and at most recipeList.size() Work out the exclusive upper bound, which must be at least 0 and at most recipeList.size() Take the sublist So: int start =... more 2/21/2014 12:20:40 PM
Assuming your start/end "points" are actually lines, you basically need to read from the start and skip the lines until you reach the right one. Here's an easy way of doing it using File.ReadLines: var lines =... more 2/21/2014 11:46:20 AM
Your event element is implicitly in the same namespace in the XML due to namespace defaulting, so you should specify that in your declaration: public class EventResponseData { [XmlElement(ElementName = "event", Namespace =... more 2/21/2014 10:29:38 AM
This works but I have a hazy memory of being told it unnecessarily copies the integers into arguments a and b and then into m_a and m_b. Yes, the values are copied into the parameters a and b, and then into the state of the object... more 2/21/2014 10:01:37 AM