News for hackers. Stuff that matters.
Re:Get Ready For C# 4.0 by InclinedPlane on Tuesday May 11, 2010 @05:58AM (#1337380)
The real advantage of named parameters is the ability to have optional parameters as well. Which means that instead of:

   var c = new X(3, "blue", null, null, null, null, false, true, null, 1, null);
(which, sadly, is an all too common implementation pattern), you can have:

   var c = new X(foo: 3, bar: "blue", baz: false, quux: true, wibble: 1);
Which seems quite a bit better.

Another advantage of named/optional parameters is that you can use them in the construction of immutable objects, whereas you don't get that advantage if you use settable properties.

There are no comments on this comment yet.