Browsing 7239 questions and answers with Jon Skeet
My question: Why is ConcurrentDictionary implemented like that? I believe it's to encourage you to think of the concurrency implications - that multiple threads may be writing the same keys at the same time. Adding an existing key is... more 2/18/2014 8:15:28 AM
I wondered if there was a way to set up an abstract class to minimise my code repetition a bit No, there isn't. As soon as you've got an abstract class, you've got a class which can be instantiated multiple times. I've seen various... more 2/18/2014 8:08:08 AM
It sounds like you've just forgotten to implement hashCode: @Override public int hashCode() { return getName().hashCode(); // Consistent with equals } Note that you don't really need to perform an ordering comparison in your equals... more 2/17/2014 4:15:15 PM
JSR-310 - the new date/time API in Java 8 - handles this already. From the Instant docs: For practicality, the instant is stored with some constraints. The measurable time-line is restricted to the number of seconds that can be held in... more 2/17/2014 12:48:50 PM
What is the defined behaviour in C# for when an exception is thrown before setting the value of an out parameter, and you then try to access the parameter? You can't do so. The variable will still not be definitely assigned, unless... more 2/17/2014 9:49:47 AM
I'd use an XML API: XElement element = XElement.Parse(text); string value = element.Value; byte[] bytes = Convert.FromBase64String(value); more 2/17/2014 9:47:06 AM
Well it looks like you should be able to use: using System.Linq; ... var children = item.GetChildren().ToList(); more 2/17/2014 8:35:16 AM
Don't use string conversions at all. Use a PreparedStatement, and the setTimestamp method. // TODO: Cleanup etc PreparedStatement st = conn.prepareStatement( "select * from table1 where searchdate >= ? and searchdate <... more 2/16/2014 3:48:04 PM
It sounds like you're just after a cast: public static String castToString(Object o) { return (String) o; } This will throw a ClassCastException if o is a non-null reference to a non-String type. (If o is a null reference, the cast... more 2/16/2014 3:29:12 PM
Your client sends the bytes of a line, and waits for a response, keeping the stream open. Your server waits for a line break (or the end of the stream, i.e. the connection being closed) before ReadLine returns. So both sides are waiting... more 2/16/2014 1:02:58 PM