我应该使用«这个。»关键字在OOP编程哪里可以跳过?使用它的任何益处? [英] Should I use «this.» keyword in OOP programing where it's possible to skip it? Any benifits of using it?
本文介绍了我应该使用«这个。»关键字在OOP编程哪里可以跳过?使用它的任何益处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
什么时候使用this关键字?
在OOP中,有时我们可以写 .PropertyName = VALUE
,有时我们可以跳过 this
。并且只需写 PropertyName = VALUE
。
In OOP sometimes we can write this.PropertyName = VALUE
and sometimes we can skip this
. and just write PropertyName = VALUE
.
所以我的问题是,如果我们总是使用 this。
?
使用/写这个
对应用程序性能有什么影响,还是只是使代码更清晰?
So my question is, should we try always to use this.
?
Does using / writing this
have any effect on application performance or does it just make the code a little bit clearer?
感谢。
推荐答案
性能不应该有任何差异。它纯粹是一种风格决定。
There shouldn't be any difference in performance. Its purely a style decision.
这篇关于我应该使用«这个。»关键字在OOP编程哪里可以跳过?使用它的任何益处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文