一类问题的多个构造函数

bob*_*205 2 c# constructor

我习惯用C++做这件事.这是不允许在C#中?

BasicCtor(int a)
{
   return BasicCtor(a, "defaultStringValue"); 
}

BasicCtor(int a, string b)
{
    //blah blah

}
Run Code Online (Sandbox Code Playgroud)

在C#中,我既不能返回构造函数的调用,也不会调用它来返回.C#允许我想做什么吗?:P

Joh*_*ers 6

BasicCtor(int a) : this(a, "defaultStringValue")
{
}

BasicCtor(int a, string b)
{
    //blah blah

}
Run Code Online (Sandbox Code Playgroud)