What is 'this' keyword used for in C#?
Experience Level: Junior
Tags: C#
Answer
'this' keyword works like a reference to an object that holds the method that is currently being executed. In the example below the 'this' keyword is used to refer to the property VolumeLevel. The keyword 'this' is not needed most of the time, so whenever you see it, you should be thinking whether the keyword is really needed and whether it couldn't be removed.
Related C# job interview questions
What is happening and in what order when a new object in being created C#?
C# JuniorWhat is 'return' keyword used for in C#?
C# JuniorIn C# how do you call one method from another method where both method are inside of the same class?
C# JuniorWhat is an attribute in C#?
C# JuniorWhat must every method have in C#?
C# Junior