optional in C#
In the VB.NET world , when we declare a function we can use "optional" to set a default value to a variant .
I want to have the same result in C# today , because there is no keyword like "optional" in C# , we can use the
object program concept to solve it , below is the source .
VB.NET
Private Function test(ByVal strA As String, Optional ByVal strB As String = "default") As String
End Function
C#
private string test(string strA)
{
test(strA, "default")
}
private string test(string strA, string strB)
{
}
through the convert tool in http://www.developerfusion.com/utilities/convertvbtocsharp.aspx we can get the same result .