I accidentally overloaded a constructor in C# as follows:
public MyClass(string myString)
{
// Some code goes here
}
public MyClass(string myString, bool myParameter = false)
{
// Some different code here
}
With this code my project compiled fine. If I call the constructor with just a string
argument, how does C# decide which constructor I want to use? Why is this functionality syntactically allowed?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…