> Point p = new (3, 5);
At first glance, not impressive, since you could just do:
> var p = new Point(3,5);
However, it would clean up code like:
> graphics.DrawRectangle(RedBrush, new(3, 5, 2, 2))
> Point p = new (3, 5);
At first glance, not impressive, since you could just do:
> var p = new Point(3,5);
However, it would clean up code like:
> graphics.DrawRectangle(RedBrush, new(3, 5, 2, 2))
> graphics.DrawRectangle(RedBrush, new Point(3, 5, 2, 2))
what's the advantage of the first example? i prefer the second, because i don't have to look at the definition of DrawRectangle in order to know that the second argument is a 'Point' object.
It's still nice to have the option in cases where it improves readability (maybe with named args or sth)
new List<KeyValuePair<string,int>> { new (“a”, 1), new (“b”, 2) }
versus having to barf out the type name for every element will be REALLY nice.
Saves some typing but it also has refactor implications too. If you change the parameter type, it would change the object being constructed.
var p = Point(3,5).
For cases like this it's no big deal, but deep/complex initalizers (like expression trees, etc.) look horrible in C# unless you create static helper fn's to init objects.