What is Constructors, explain with syntax

Answer

A is special method of the class that will be automatically invoked when an instance of the class is created is called as constructor.

Constructors are mainly used to initialize private fields of the class while creating an instance for the class.

When you are not creating a constructor in the class, then compiler will automatically create a default constructor in the class that initializes all numeric fields in the class to zero and all string and object fields to null.

Syntax.
[Access Modifier] ClassName([Parameters])
{
}

All c sharp Questions

Ask your interview questions on c-sharp

Write Your comment or Questions if you want the answers on c-sharp from c-sharp Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---