What is Constructor?

A special method of the class that is automatically invoked when an instance of the class is created is called a constructor. A constructor is a special method that is used to initialize objects. The advantage of a constructor, is that it is called when an object of a class is created.

When we create instance of a class a default constructor is invoked automatically having the same name as Class . Some key points,

  • Constructor is used to initialize an object (instance) of a class.
  • Constructor is a like a method without any return type.
  • Constructor has the same name as class name.
  • Constructor follows the access scope (Can be private, protected, public, Internal and external).
  • Constructor can be overloaded.

#c#

Can A Class Work Without Constructor In C#
1.10 GEEK