Browsing 7239 questions and answers with Jon Skeet
If you really must use ArrayList, and assuming you're using .NET 3.5 or higher, you can use the LINQ Cast method to convert it to a sequence of strings: // .NET 4 and higher File.WriteAllLines(@"c:\actors.txt",... more 10/21/2013 5:49:15 AM
You're decrementing first twice: once each time the outer loop iterates, and once each time the inner loop starts iterating. So after printing 2 5 it hits the end of the inner loop, and hits the first-- from the outer loop. Then as it... more 10/20/2013 7:31:51 PM
It sounds like you should be returning the list reference, rather than using it as a parameter - otherwise the fact that you're assigning a different value to it in the first statement of the method body makes it pointless: private... more 10/20/2013 3:06:19 PM
An initializer block can only throw unchecked exceptions, or checked exceptions which are declared to be thrown by all constructors. (This includes exceptions which are subclasses of those which are declared.) You can't throw a checked... more 10/20/2013 2:38:33 PM
Your implementation is failing because when you (implicitly) call iterator(), your itr variable still refers to just the "null value" node. You only set it to any other value in the next() method, which isn't called until later. However,... more 10/19/2013 9:37:08 PM
I understand that the base-Property is used instead of "my" property. Is there a way to change that? Well not really. The problem is that it's not a virtual property, and you've just introduced a new property with the same name - it's... more 10/19/2013 9:30:25 PM
It could well be that the task you're running is completing immediately - which means that the await doesn't even need to schedule a continuation. An async method only schedules a continuation when it needs to; if you await something which... more 10/19/2013 8:00:08 PM
I thought obj refers to a particular element in an array, so if I initialize it, the array element will be initialized as well. Why isn't that happening? No, obj has the value of the array element at the start of the body of the... more 10/19/2013 8:15:28 AM
Well, the second line won't create a new object, because you've already used the same string constant in the first line - but s1 and s will still refer to different objects. The reason the second line won't create a new object is that... more 10/19/2013 8:10:11 AM
It seems like shape class serves no purpose. I can't do an impementation of getArea in shape class, since different shapes calculate area differently. I could just remove shape class and make my code simpler. Suppose you have a... more 10/19/2013 8:04:50 AM