C# language
can i create two same name constructer in single class.
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Jul 6, 2012, 1:40 AM EDT
However, you can have multiple constructors as long as their signatures (i.e. the number and/or type(s) of their parameters) differ from each other.
For example, this class compiles fine:
class MyClass
{
public MyClass()
{
// code
}
public MyClass(int i)
{
// code
}
// other class member declarations
}