---
title: "this keyword in CSharp .NET"  
description: "The ‘this’ keyword refers to the current instance of the class. ‘this’ keyword is used when we want to track the instance, which is invoked to perform"  
author: "Anonymous User"  
published: 2010-07-31  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/96/this-keyword-in-csharp-dot-net  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# this keyword in CSharp .NET

The ‘this’ keyword refers to the current instance of the class. ‘this’ keyword is used when we want to track the instance, which is invoked to perform some calculation or further processing relating to that instance.\

##### Example

```
      int a,b;                public void withThis(int a, int b)        {     //here this.a and this.b will refer to a,b of class not of this method.            this.a = a;            this.b = b;        }        public void withoutThis(int a, int b)        {            a = a;            b = b;        }         private void btnThis_Click(object sender, EventArgs e)        {            a = 0;            b = 0;            withThis(5, 4);            MessageBox.Show(a.ToString() + "\n" + b.ToString());                }
```

![this keyword in CSharp .NET](https://www.mindstick.com/mindstickarticle/62c4eed1-6835-4fd5-9de8-6b879dcca909/images/cbe49848-31bc-4278-831a-1ee0b005a999.png)

Here value of a and b is changed to the value of argument passed

```
        private void btnWithoutThis_Click(object sender, EventArgs e)        {            a = 0;            b = 0;            withoutThis(5, 4);            MessageBox.Show(a.ToString() + "\n" + b.ToString());        }
```

![this keyword in CSharp .NET](https://www.mindstick.com/mindstickarticle/62c4eed1-6835-4fd5-9de8-6b879dcca909/images/c046808c-d505-49d8-a8e7-58fd0d0c5cd1.png)

Here value of a and b doesn’t changed to the value of argument passed

---

Original Source: https://www.mindstick.com/articles/96/this-keyword-in-csharp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
