The .NET 4.0 Framework adds several new features to the C# language. Two closely related language features are named parameters and default parameter values. As usual, the best way to explain is by way of an example. A standard C# function which computes and returns the volume of some hypothetical geometric object might look like this:

Notice that it might be easy to accidentally switch the values for the height (5) and radius (4) parameters. In .NET 4.0 you can specify default parameter values as in this example where I indicate a parameter value to use if one is not explicitly provided in the function call:

Here I am using named parameter syntax to make the call to the function more clear with regards to parameter values. So, what’s the point? Well, in my opinion, I think named parameters are a Good thing, but default parameter values are a Bad thing. Named parameters can add clarity to code at the minor expense of wordiness. Default parameter values make code slightly less clear in many situations. I believe that in most cases providing overloaded versions of a function is a better approach than using dfault parameter values. Interestingly, I used to use the Ada programming language a lot in the 1980s. Ada has named parameters and default parameter values so these new .NET 4.0 features aren’t so new to the field of programming languages. Module testing in .NET 4.0 should now take into account and deal with these new language features if they are used when defining methods and functions.