Earlier quoted context omitted.
I can't see var going anywhere, many times you aren't directly creating a new object, but getting a generated object from something ( like linq) which tends to have more complicated type signatures.
Agreed that `var` isn't going anywhere, but this feature's best use case is with complex generics/enumerables and things like anonymous tuple types. For example: // old: var x = new List > { new KeyValuePair ("a", 1), new KeyValuePair ("b", 2) }; // new var x = new List > { new("a", 1), new("b", 2) };
// ListExtensions.cs
internal static class
ListExtensions
{
public static void Add(this List> list, string key, int value)
{
list.Add(new KeyValuePair(key, value));
}
}
// new w/extension method
var x = new List>
{
{"a", 1},
{"b", 2},
};