Browsing 7239 questions and answers with Jon Skeet
You're writing the character '4', '1' or '2' - which is encoded in UTF-16 as 0x00 0x34 (etc). It seems to me that you want to write a short or ushort value or 4, 1, or 2: short lineDepth = 4; if (MaxDev <= 127) { lineDepth = 1; }... more 3/19/2014 1:56:58 PM
Dynamic typing and overloading could help here, if you don't mind using dynamic: object ConvertToListIfNecessary(dynamic input) { return MaybeToList(input); } private IList<T> MaybeToList<T>(IEnumerable<T> input) { ... more 3/19/2014 8:39:18 AM
Just use an if statement: @if (Model.LoginFailed) // Or whatever... { @Html.LabelFor(m => m.WrongLogin); } more 3/19/2014 7:11:31 AM
Yes — your cast will fail (with an exception), and then you're unconditionally calling stmt.close() in the finally block, even though stmt is still null... hence the NullPointerException. Basically, don't do this — use... more 3/19/2014 7:06:43 AM
The type of the variable c1 is List<Integer>. That just means that the value of c1 at any time has to either be null, or a reference to an object whose type implements List. However, the type of the object that the value of c1... more 3/18/2014 6:47:44 PM
Reading file directly into byte array gives a different output compared to reading data into a String and then getting bytes from it. Well, it might. And it might not. It depends on how you've read the file as text, and how you've... more 3/18/2014 6:42:39 PM
Why is it comparing a single object and an IEnumerable is valid for RefTypes? Because it's entirely feasible that it will return true: class CunningFooRef : FooRef, IEnumerable<FooRef> { // Implementation... } FooRef... more 3/18/2014 6:34:07 PM
Your MyThread.run() method is overriding Thread.run() - and it's the Thread.run() implementation which calls the run method on the Runnable passed into the constructor. As documented: If this thread was constructed using a separate... more 3/18/2014 6:31:11 PM
Okay, so it sounds like the problem is that there's no equivalent of Type.MakeByRef in .NET 1.1. You may be able to use Type.GetType("System.Int32&") to get that: MethodInfo method = t.GetMethod("GetEncodedData", ... more 3/18/2014 3:38:12 PM
Your expectation is incorrect, basically. The value you've given is 04/30/2014 23:00:00 +11:00 - because it's UTC 04/30/2014T12:00:00 (as verified with Epoch Converter), but with a local offset of +11 hours. So the local time is 11pm. In... more 3/18/2014 3:18:39 PM