The keyword this in C# is slightly different from other languages. I’ve been googling for a while, but I cannot find an article that will sum up all.
How can I use this in C#?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What is “this”? It is a keyword used in many object-oriented programming languages to refer to the current object. It can be implemented as a pointer (f.e. C++) or reference (f.e. Java), but in C# it has a few different meanings.
Classes
We can use “this” in 3 different contexts
example:
Indexers
Define an indexer for the type to have array-like semantics.
Extension methods
Structures