A constructor is a special method in a class that is automatically invoked when an object of the class is created. It is used to initialize objects.
Syntax
class ClassName
{
public ClassName()
{
// Initialization code
}
}
Types of Constructors in C#
1. Default Constructor
2. Parameterized Constructor
3. Copy Constructor
4. Static Constructor
5. Private Constructor