Browsing 7239 questions and answers with Jon Skeet
You're calling toString on a byte[]. Arrays don't override toString(), so you're seeing the implementation in Object: The toString method for class Object returns a string consisting of the name of the class of which the object is an... more 11/4/2013 4:37:14 PM
It's because of an optimization which is unfortunately slightly broken in the face of unexpected CLR conversions. At the CLR level, there's a reference conversion from a Foo[] to int[] - you don't actually need to cast each object at all.... more 11/4/2013 4:28:57 PM
This is a bad start: for (int i = 0; i < arrayBeingSearched.length; i++) That's a linear search, with something else within it. I haven't followed exactly what you're doing, but I think you should probably start again... with a... more 11/4/2013 4:18:50 PM
My question is simple, is it imperative that a method included in an interface HAS to return some value? No, absolutely not. You can declare a void method in an interface, and indeed there are plenty of standard library interfaces... more 11/4/2013 11:04:30 AM
You only use Key with anonymous types - not object initializers. So your VB code should be: lst.Add(New Makes() With { _ .Id = Convert.ToInt32(dr("ID")), _ .MakeName = Convert.ToString(dr("CHASSIS_NO")), _ .Model =... more 11/4/2013 10:44:26 AM
If there is no need to create new Thread in ThreadPool scenario, then how it works with same thread which just finished its run method, will that Thread can be used again? Simple - the original thread never actually completes. It just... more 11/4/2013 10:37:54 AM
In the second case, you're actually evaluating the query twice. Once when you use foreach, and then another time when you create the ObservableCollection. You'll end up with two distinct sets of objects, which you could validate by adding... more 11/4/2013 7:02:09 AM
In other words: is the finally block still guaranteed to run even if there are no strong references to the object(/thread) left in memory? Yes. finally blocks don't get skipped like that - nor does any other code. Execution threads... more 11/4/2013 6:43:07 AM
Yes, that's what happens with structs. You need to make the changes locally, then shallow copy back again. For example: public class Foo { public Point Location { get; set; } } public class Bar { private Foo foo = new Foo(); ... more 11/3/2013 9:23:08 AM
You can't. You can't derive from array types. I'd generally advise against overriding ToString in List<T>, too - usually it's better to use composition than inheritance for things like this, in my experience. more 11/2/2013 8:52:07 PM