Is `this` keyword optional when accessing members in C#?

前端 未结 4 622
梦毁少年i
梦毁少年i 2021-01-18 01:58

I notice that if you have a private member in a class, you can access it in the class methods by just referring to it\'s name. You do not need to say this.memberName

4条回答
  •  走了就别回头了
    2021-01-18 02:50

    Yes, 'this' is implied. It can sometimes help for clarity. And it is also necessary for calling methods and need to reference the current class.

提交回复
热议问题