Browsing 7239 questions and answers with Jon Skeet
You're not doing anything with the result of PadLeft - but you don't need to do that anyway. You can just specify the number of digits (and format) in the ToString call: string result = temCode.ToString("d4"); more 2/10/2014 9:41:06 AM
If you are going to split this out, I would actually split the recursion part from the "what you do with each node" part. So something like this: public static void ApplyRecursively<T>(this IEnumerable<T> source, ... more 2/10/2014 7:44:09 AM
That certainly wouldn't do what you wanted it to. ForEach doesn't return anything. It executes the delegate you provide against each item in the list, and that's all. Personally I'd just use Where with a foreach loop: foreach (var item... more 2/10/2014 7:23:59 AM
But I can not understand why no object? It's also a reference type? Yes, both double[] and object are reference types, so null is implicitly convertible to both of them. However, member overloading generally favours more specific... more 2/9/2014 8:52:48 PM
The stack overflow isn't in your constructor. It's when your main method calls add on your BigNumber. This is the first problem: public BigNumber add(BigNumber other) throws CloneNotSupportedException { return ((BigNumber)... more 2/9/2014 7:47:32 PM
I would split the list into two: items that contain apple, and items that don't. Then sort the apple-containing list, and then append the non-apple-containing list. List<String> apples = new ArrayList<>(); List<String>... more 2/9/2014 4:13:46 PM
The return type is clearly an integer array (as specified in the method definition), but I have not assigned the returned data to any integer array, but the program still works. Yes, because it's simply not an error to ignore the... more 2/9/2014 3:36:21 PM
No, because you're trying to make the compile-time type of p depend on the execution-time type of the value within the collection. Imagine you're writing a compiler, and you're provided with this code: public void Foo(MagicCollection... more 2/8/2014 4:12:20 PM
It's not really a static/non-static difference - it's a difference in the compile-time type of the reference you're trying to call the method on. In the instance method, you're implicitly calling it on this, which has a compile-time type... more 2/8/2014 1:56:48 PM
My question is: does java.awt.* import everything from awt? It imports all the classes in java.awt, but that's all. And if so why is this necessary? import java.awt.event.ItemEvent; Because that's not in java.awt - it's in... more 2/8/2014 1:53:33 PM