C#: Method optional parameter

Please see my other Web articles.

Declare default value for a parameter to make it optional

In this article I’ll demonstrate how to make method parameters optional to add flexibility when invoking methods.

To make a parameter optional, simply declare a default value for it in the signature.

Then, during invocation, any parameters which don’t receive a argument, use the default value instead.

This can alleviate the need for method overloading when an argument value isn’t known at design time.