Resolving Ambiguities with Optional Parameters and Named Arguments

后端 未结 3 749
北恋
北恋 2021-01-23 07:36

I have two methods on my project as defined below:

void Person(int ID, double height = 0.0, string team = \"Knights\")
{
   //my codes
}
void Person(int ID, d         


        
3条回答
  •  旧时难觅i
    2021-01-23 07:50

    TL:DR The first method (most specific) will be called because in that case no parameter needs to be bound using default values.

    For an in-depth discussion refer to this article.

提交回复
热议问题