this keyword is used to refer to the current instance of the class. It is used to access members from the constructors, instance methods, and instance accessors. this keyword is also used to track the instance which is invoked to perform some calculation or further processing related to that instance. Following are the different ways to use ‘this’ keyword in C# :
Program 1: Using ‘this’ keyword to refer current class instance members
Program 2 : Using this() to invoke the constructor in same class
Parameter Constructer Called Non-Parameter Constructer Called
Program 3: Using ‘this’ keyword to invoke current class method
Inside show funcion Inside display function
Program 4: Using ‘this’ keyword as method parameter
a = 10 b = 20
Program 5: Using this keyword to declare an indexer
Sun Mon Tue Wed Thu Fri Sat
- Static keyword in C#
- C# | is Operator Keyword
- C# | as Operator Keyword
- Is vs As operator keyword in C#
- LINQ | Let Keyword
- C# | finally keyword
- typeof Operator Keyword in C#
- How to implement is functionality without using is keyword in C#
- Difference between readonly and const keyword in C#
- Invoking an overloaded constructor using this keyword in C#
- How to style the Border of ListBox in C#?
- How to set the Font of the ListBox in C#?
- How to add Items in ListBox in C#?
- How to set the Foreground Color of a ListBox in C#?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.