comment 0

C# Constructor Chaining

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.

 

Filed under: C#

Leave a Reply

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