【问题标题】:Should I use «this.» keyword in OOP programing where it's possible to skip it? Any benifits of using it? [duplicate]我应该使用«this。» OOP 编程中的关键字在哪里可以跳过?使用它有什么好处吗? [复制]
【发布时间】:2010-10-13 01:47:27
【问题描述】:

可能重复:
When do you use the “this” keyword?

在 OOP 中,有时我们可以写 this.PropertyName = VALUE,有时我们可以跳过 this。然后写PropertyName = VALUE

所以我的问题是,我们应该尽量使用this.吗? 使用/编写this 对应用程序性能有什么影响,还是只是让代码更清晰一点?

谢谢。

【问题讨论】:

  • 尝试为它编写一个基准。我猜它们在编译语言中是相同的。
  • 如果不是,你的编译器不好。

标签: performance oop coding-style


【解决方案1】:

性能应该没有任何差异。这纯粹是一种风格决定。

【讨论】:

    猜你喜欢
    • 2011-01-21
    • 2011-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-17
    • 2010-10-04
    • 2017-08-25
    • 1970-01-01
    相关资源
    最近更新 更多