Bill Wagner has explored two related upcoming features in the C# language: named and optional parameters. These features were added to the language to support COM interoperability, specifically COM interoperability with Microsoft Office.
For a variety of historical reasons, Office COM APIs have large numbers of parameters, several of which have reasonable defaults. In addition, while you may want to use many of the defaults, you may need to specify a value for some of the parameters later in the list. It would be great to call those Office methods having 15 or more parameters by only specifying those parameters where you want something other than the default. Optional and named parameters enable that for you in C# 4.0.
Named and Optional Parameters Explained
Named parameters allow you to call a method by specifying which argument in a method call refers to which formal parameter. Suppose someone had written this trivial Subtract method:
public static int Subtract(int left, int right)
{
return left - right;
}
All three of these calls are equivalent:
result = Subtract(7, 5);
result = Subtract(left: 7, right: 5);
result = Subtract(right: 5, left: 7);
If you don’t specify a name for any of the parameters, the normal order is used. Notice that you can rearrange the order of the parameters by specifying them by name.
Optional parameters enable you to specify a default value for any parameter to a method. Any parameters that have default values must be at the end of the argument list. Optional parameters must be compile-time constants.
One of the things I like the most about named parameters is that you can improve the readability of code.
Please read the complete article here:
Visual Studio Magazine : Looking Ahead to C# 4.0: Optional and Named Parameters