Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

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

Tags: default

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:



This post first appeared on Code Snippets, please read the originial post: here

Share the post

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

×

Subscribe to Code Snippets

Get updates delivered right to your inbox!

Thank you for your subscription

×