Constructors are the special methods invoked when an object is first created.
The constructor is created with class name.
Some distinct characteristics of constructors:
Constructors do not have any return type.
Constructors are always public.
Constructor is automatically declared by CLR, whenever the class is instantiated.
Example:
Class A
{
A ()//constructor name same as class name
{
//body
}
}
No comments:
Post a Comment