- Its name must be same as "classname".
- It must be defined as "public method".
- It can be defined with/without arguments.
- It can't return any value. So, no return type specification is required.
- "Constructor overloading" is possible. Writing multiple constructors in the same class is called as "Constructor overloading".
Define rules of Constructors
Labels:
C#.Net
Define “this” Keyword
This is similar to ―this pointer in C++.
It represents current working object.
It is used to access the members of current working object.
Current object: The object, with which object, the method is called.
“this” keyword can‘t be used in the static methods, because static methods doesn‘t have current object.
It represents current working object.
It is used to access the members of current working object.
- this.field
- this.property
- this.method()
Current object: The object, with which object, the method is called.
“this” keyword can‘t be used in the static methods, because static methods doesn‘t have current object.
Labels:
C#.Net