---
title: "Can “this” be used within a static method in c#"  
description: "Can “this” be used within a static method in c#"  
author: "Manoj Bhatt"  
published: 2016-01-24  
updated: 2017-11-17  
canonical: https://www.mindstick.com/forum/33924/can-this-be-used-within-a-static-method-in-c-sharp  
category: "c#"  
tags: ["c#", ".net"]  
reading_time: 2 minutes  

---

# Can “this” be used within a static method in c#

Hi All..I want to know , can i used 'this' [keyword](https://www.mindstick.com/forum/33572/sql-inner-join-keyword) inside a [static method](https://www.mindstick.com/blog/440/creating-static-methods-in-c-sharp).\
Thank you.

## Replies

### Reply by Anonymous User

Post is removed by the Admin.

### Reply by Shiva Shukla

We can't use this in [static](https://www.mindstick.com/articles/12098/the-static-keyword-the-static-methods) method because keyword 'this' returns a reference to the current instance of the class containing it. Static methods (or any static member) do not belong to a particular instance.The "this" keyword is a special type of reference variable that is implicitly defined within each constructor and non-static method as a first parameter of the type class in which it is defined.

```
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace this_example{    class Program    {        public class Demo        {            int age;            string name;             public Demo(int age, string name)            {                age = age;                name = name;             }             public void Show()            {                Console.WriteLine("Your age is :" + age.ToString());                Console.WriteLine("Your name is : " + name);            }        }         static void Main(string[] args)        {            int _age;            string _name;             Console.WriteLine("Enter your age : " );            _age=Int32.Parse(Console.ReadLine());             Console.WriteLine("Enter your name : ");            _name=Console.ReadLine();             Demo obj = new Demo(_age, _name);             obj.Show();            Console.ReadLine();         }    }}
```

***Output of the above program will be:***![Can “this” be used within a static method in c#](https://www.mindstick.com/mindstickforums/7a0b6a6b-e0db-473d-9060-d8c722c64272/images/5a4063e9-27af-4ae0-96f0-2fdc966287eb.png)


---

Original Source: https://www.mindstick.com/forum/33924/can-this-be-used-within-a-static-method-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
