"this" Keyword

Description :

"this" keyword is used to represent the current instance of class.

"this" keyword is used to refer current instance members.

Lets we see the simple example

Example :

Here there is simple class "Student". "Student" class has the variable "studentName" member and method "getStudentName()."

Value of member "studentName" is assigned by constructor by the "this" keyword.

When object of the "Student" class , constructor is called and value is assigned in the class member "studentName" with "this" keyword.






Output :






Comments

Popular posts from this blog

Comments in C#

Assembly Manifest