This article gives a brief introduction, features of constructors their usage and also an idea of how to use C# constructors.

Why Constructors?

Initialization of values of different variables is critical in any application development. C# does initialize simple data-types to default values as per the language specification in the .Net framework, but for classes that are user specific, it is obvious that you would be the only one who can decide what is an ideal default value. The means of achieving this is Constructors. There is also a perception that constructors can only be used beyond initialization, which is true to some extent. We will examine them in the following sections.

Features of a Constructor

The following section deals with the how best to leverage the features of Constructors in our classes.

How to Use Constructors?

Also note that the constructor initializers "base" and "this" are the only keywords that can be used when making a call to the base constructor, also any one among these can be specified.

Conclusion

Proper design of constructors goes a long way in solving some core problems faced in your class design. C# supports enormous flexibility to accommodate the use of various types of constructors. One has to judge the need of the application and never overlook the importance of constructors.