Why keyword 'this' cannot be used in a static method?

后端 未结 13 1808
遇见更好的自我
遇见更好的自我 2020-12-16 14:13

Why can\'t the keyword this be used in a static method? I am wondering why C# defines this constraint. What benefits can be gained by this constraint?

[

13条回答
  •  天命终不由人
    2020-12-16 14:35

    The short answer for you will be: this refers to an instance of a class which is non existing in a static scope.

    But please, look for a good book/class and try to understand basic object oriented concepts before going further on any object oriented programming language.

提交回复
热议问题