Flyinsky

志在四方,浪迹天涯

导航

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 .

posted on 2004-05-27 13:56  flyinsky  阅读(729)  评论(0编辑  收藏  举报