Browsing 7239 questions and answers with Jon Skeet
You're just confusing yourself in the debugger, basically. A HashMap has an entry set - and that entry set refers to the containing map. All you're doing in the debugger is navigating from the map to the entry set, back to the map, back... more 2/23/2016 10:40:02 AM
Basically, you're not using the reader properly. DbDataReader.Read() returns a Boolean value indicating whether or not it's managed to need another row of results. You're currently treating it as if it returns the next result, returning... more 2/23/2016 6:48:28 AM
You're trying to write code directly within the class declaration. A class declaration can only directly contain member declarations. It can't contain arbitrary statements such as newObject.Name = "Johnny" nor can it use var, which is only... more 2/22/2016 4:02:04 PM
Your preferred format simply isn't JSON. Values in JSON are only: Numbers (no differentiation between integers and non-integers) Strings Objects Arrays Boolean true/false null That's it. So the only way of preserving extra information... more 2/22/2016 2:08:16 PM
As ever, the official documentation is the C# specification. The important part is that this is just a throw statement. It has two parts (in this case): The keyword throw An expression which determines the exception to throw In this... more 2/22/2016 10:34:48 AM
Basically, you're writing to System.out and System.err. It's unclear (and implementation-specific) exactly how much data those will buffer, or when they will be flushed, but you shouldn't necessarily expect that to be consistent every... more 2/22/2016 7:05:49 AM
You haven't closed the writer. The writer buffers data, so if you just let it get garbage collected without flushing or closing it, the file handle will be closed without ever writing the data to the file. You should ideally do this with... more 2/21/2016 5:16:01 PM
It sounds like you need one class for "a statistic" - and then a Dictionary<PlayerStat, int> (or whatever the value would be). The PlayerStat class would know about the abbreviation, description and XML attribute name - and I'd... more 2/21/2016 7:55:07 AM
Just use java.lang.reflect.Array.newInstance: Object byteArray = Array.newInstance(byte.class, 4096) Object shortArray = Array.newInstance(short.class, 4096); You can use the other methods in Array to manipulate the array. more 2/20/2016 12:14:26 PM
Well you could start off by making them generic: public TResult Spy<TResult>(Func<TResult> method) { methodCalls.Add(method.Method.Name); return method(); } public TResult Spy<TArg, TResult>(Func<TArg,... more 2/19/2016 6:30:12 PM