Click here to Skip to main content
11,574,473 members (57,115 online)
Click here to Skip to main content

Tagged as

How to call an overloaded constructors in C#

, 20 Sep 2011 CPOL 4.5K 1
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

You may also be interested in...

Comments and Discussions

 
GeneralAlso should be good to note, this was introduced in .NET 4 a... Pin
Tony D Great27-Sep-11 2:46
memberTony D Great27-Sep-11 2:46 
GeneralIf you do this, you can no longer use Activator.CreateInstan... Pin
Richard Deeming22-Sep-11 7:02
memberRichard Deeming22-Sep-11 7:02 
GeneralHi Robert, in this scenario you are correct, but sometimes y... Pin
Reiss20-Sep-11 21:02
memberReiss20-Sep-11 21: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
Web03 | 2.8.150624.2 | Last Updated 20 Sep 2011
Article Copyright 2011 by Robert Ludwig
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid