Default Parameter in .NET 4(C#)
Posted
by Yousef_Jadallah
on ASP.net Weblogs
See other posts from ASP.net Weblogs
or by Yousef_Jadallah
Published on Fri, 16 Apr 2010 17:44:08 GMT
Indexed on
2010/04/16
17:53 UTC
Read the original article
Hit count: 434
Visual Studio 2010
|.NET
During my using for the new release .NET 4, I notice that C# support default (Optional) Parameters, after thousands of complains form C# programmer- especially it was supported by VB.NET- now it's available.
Let's create Test function with Optional Parameter
private void TestFunction(string para1, string para2 = "Default") { Response.Write("Parameter one =" + para1 +" , Parameter two="+ para2 ); }
Then, if you try to call this method the Intellisense display likes this:
Therefore,if you don’t pass the second parameter the value of para2 will be “Default”.
With this new future in C#, you can ignore many overload functions event it was acceptable solution!
© ASP.net Weblogs or respective owner