C# 4.0 brings the idea of named parameters to C#. While optional/default arguments are of questionable value (this is from my VB.NET days), named parameters can really clear up the meaning of a method call. We’re already faking named parameters, as seen here in the ASP.NET MVC codebase:
return GenerateUrl(
null /* routeName */,
actionName,
null /* controllerName */,
new RouteValueDictionary(valuesDictionary));
Obviously the above example isn’t compile-time safe and comments lie to you, so it will be nice to be able to provide named parameters, especially when the number of arguments grows in a method call. Something to look forward to.
Posted
Dec 18 2008, 09:10 AM
by
bogardj