可能重複:
When do you use the 「this」 keyword?使用或不使用「this」關鍵字來引用同一個類中的方法有什麼區別?
如果我有下面的例子:
public class MyClass {
private void MyMethod1()
{
...
}
private void MyMethod2()
{
this.MyMethod1();
...
}
}
在 「MyMethod2」 有沒有使用中的差異「this.MyMethod1()」還是「MyMethod1()」?性能,安全性,良好的做法,或其他?我問這個問題,因爲通常我不會使用「this」來調用同一個類中的方法,但是我得到了使用它的其他人開發的代碼......也許我錯了......或者不是!
對不起,看起來像一個愚蠢的問題,但我是「好奇」畢竟。謝謝!
Myclass :: MyMethod1(); – adhanlon 2010-08-19 20:57:26
http://stackoverflow.com/questions/23250/when-do-you-use-the-this-keyword http://stackoverflow.com/questions/1845573/c-using-the-this-keyword-in- this-situation http://stackoverflow.com/questions/843288/c-when-to-use-this-keyword-closed – dtb 2010-08-19 20:58:53