Constructor Chaining in C#

[AdSense-A]

C# Constructor chaining is something pretty simple to accomplish in most classes. It is pretty common to have multiple constructors, but chaining them makes it a little easier to manage.

Here is a simple way to accomplish constructor chaining:

Now when you call the constructor with the string parameter, it will automatically call the base constructor passing in a new Account object that is created from the id.

This is pretty straight forward and easy to use. It makes your code easier to maintain as well.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Enter Captcha Here : *

Reload Image

This site uses Akismet to reduce spam. Learn how your comment data is processed.