Browsing 7239 questions and answers with Jon Skeet
If you really want binary compatibility then yes, you can't add even an optional parameter. What you can do is add an overload: Before: public static string GetData(string name, string surname) { // Real code } After: public... more 9/12/2016 9:59:23 AM
It creates a single object, which is an instance of B. It's already a B when the A constructor executes, as you'll see if you change your code to: class A { public A() { System.out.println(getClass()); } } class B extends... more 9/12/2016 7:08:32 AM
It would make a difference if the original variable were read during the course of the method. This could happen because: Two parameters were both provided using the same underlying variable The method invoked more code that read from... more 9/11/2016 8:56:50 PM
Now would be a good time to learn about LINQ - you want Skip(1) to skip the first element. Then you can use ToArray to create an array if you really need to. For example: string[] original = { "a", "b", "c" }; IEnumerable<string>... more 9/10/2016 4:16:20 PM
There are three options here. In my preferred order, they are: Start using LINQ instead of ConvertAll: List<double> appliedList = new List { 1, 2, 3 }.Select(f).ToList(); Create a converter to start with: Converter<int,... more 9/9/2016 10:41:29 AM
There's no ToDictionary method that gives this in a single call, as there are no overloads that provide the index, but you can use the Select overload which accepts a Func<T, int, TResult>: var dictionary = list.Select((value,... more 9/8/2016 8:43:44 AM
Namely, that the indexer in the case of an T[] returns a reference to the element within the array Not really. It's more that there isn't an indexer for arrays - instead an element-access expression represents an array access instead... more 9/7/2016 3:08:49 PM
Well, you can use dynamic typing if you really want: public class Paint { public string Color { get; set; } } public class Car { public string Color { get; set; } } ... var objects = new object[] { new Car { Color = "Red"... more 9/7/2016 9:24:18 AM
If you mean "can you create a delegate like that" then the answer is "yes, but it's slightly ugly". I don't think you can use a method group conversion, but you can use reflection and Delegate.CreateDelegate, e.g. MethodInfo method =... more 9/7/2016 7:30:37 AM
They both end up with a reference to a BigInteger with a value of 0, but they're not identical in effect. In particular, as valueOf is a static method, it can make use of caching, and return the same reference if you call it... more 9/7/2016 6:21:32 AM