Explain the concept of constructor?

Technology CommunityCategory: OOPExplain the concept of constructor?
VietMX Staff asked 3 years ago

Constructor is a special method of a class, which is called automatically when the instance of a class is created. It is created with the same name as the class and initializes all class members, whenever you access the class. The main features of a constructor are as follows:

  • Constructors do not have any return type.
  • Constructors can be overloaded.
  • It is not mandatory to declare a constructor; it is invoked automatically by .NET Framework.