Roshan Rathod
Can we use "this" command within a static method?
By Roshan Rathod in C# on Oct 04 2020
  • Kiran Mohanty
    Oct, 2020 6

    No, we can’t use “this” keyword inside a static method.

    “this” refers to current instance of the class. But if we define a method as static , class instance will not have access to it, only CLR executes that block of code. Hence we can’t use “this” keyword inside static method.

    • 5
  • Varun Setia
    Oct, 2020 14

    this refers to current instance, static is a modifier that makes prevents from using class/method as part of instance. Hence, it will not work.

    • 3
  • mohammed yaseen
    May, 2021 2

    No,we cannot use this command in static class , because this command is used to describe the current object instance of that class and since we cannot create instances of static class,hence it is not possible.

    • 1
  • Shekhar Kumar
    Jan, 2021 5

    We cant access the static method with this instance. We can use type name to access the method.

    • 1
  • shashi shekhar
    Dec, 2020 11

    No, “this” command cannot be used with static method. Reason, this is used with instance ad static method can’t be used with any instance.

    • 1


Most Popular Job Functions


MOST LIKED QUESTIONS