【发布时间】:2016-08-07 14:41:46
【问题描述】:
public string GetTitle()
{
return title;
}
正如您在上面的代码中看到的,在GetTitle() 方法中,它被用于返回title 实例变量。我的问题是,如果我添加 'this' 关键字,使GetTitle() 方法变为如下所示,会有什么不同:
public string GetTitle()
{
return this.title;
}
我没有在书中或任何地方看到过后者的例子。但我在 Visual Studio 中尝试过,它仍然做同样的事情。
如果有的话,谁能解释一下有什么区别?
谢谢! :)
【问题讨论】:
标签: c# methods this keyword getter