65.9K
CodeProject is changing. Read more.
Home

How to call an overloaded constructors in C#

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.67/5 (3 votes)

Sep 20, 2011

CPOL
viewsIcon

12279

All three of the Something methods could be replaced with a single definition of the form:public Something(string name = "default", index = -1){ myName = name; myIndex= index; DoStuff();}

All three of the Something methods could be replaced with a single definition of the form:

public Something(string name = "default", index = -1)
{
    myName = name;
    myIndex= index;

    DoStuff();
}