- Constructors are special member function, which are used initializing the class data members
- In Object oriented programming constructors are quite important since initialization of data members was not allowed at the time of declaration.
- Constructors are the methods of class.
- They are called as soon as the object is created. (Note that object is created and not the reference) The name of the constructors is same as the name of the class.
- So In an encapsulated body (Class) if you will find a Method with the same name as that of class then it is a constructor and it is called as soon as the object is created.
- C# has 4 types of constructors
2. Parameterized
3. Private
4. Static
No comments:
Post a Comment