Click here to Skip to main content
Click here to Skip to main content
Alternative Tip/Trick

Tagged as

How to call an overloaded constructors in C#

, 20 Sep 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
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();
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Robert Ludwig

United States United States
No Biography provided

Comments and Discussions

 
GeneralAlso should be good to note, this was introduced in .NET 4 a... PinmemberTony D Great27-Sep-11 3:46 
GeneralIf you do this, you can no longer use Activator.CreateInstan... PinmemberRichard Deeming22-Sep-11 8:02 
GeneralHi Robert, in this scenario you are correct, but sometimes y... PinmemberReiss20-Sep-11 22:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141223.1 | Last Updated 20 Sep 2011
Article Copyright 2011 by Robert Ludwig
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid