Optional (or Default) Parameters | Get Ready For C# 4.0

Posted by Tarek N. Elsamni | Posted in , , , , , , | Posted on 01:19


I see that people have been asking for this feature since C# 1.0. Three versions later, it’s finally here.

Now you can assign a default value to a parameter right within the method declaration. The user of the method can either pass a value or simply skip the argument. In the latter case, the default value is passed to the method.

Method declaration:

Method calls:

Comments (0)

Post a Comment