<分区>
Possible Duplicate:
When do you use the “this” keyword?
我正在编写我的第一个 C# 代码,我注意到 this.foo
只有在本地名称 foo
不同于 时才是必需的>this.foo
。到目前为止,我对是否使用 this
一直不一致。
是始终使用 this
还是仅在必要时使用 this
更可取?
<分区>
Possible Duplicate:
When do you use the “this” keyword?
我正在编写我的第一个 C# 代码,我注意到 this.foo
只有在本地名称 foo
不同于 时才是必需的>this.foo
。到目前为止,我对是否使用 this
一直不一致。
是始终使用 this
还是仅在必要时使用 this
更可取?
最佳答案
我只在必要时使用this
。大多数时候我没有区分局部变量和类变量的问题,所以除非需要,否则我不会打扰
关于C# "this"过度使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4938390/