有时可能会混淆阅读引用同一类(或基类)的其他实例成员的实例成员中的代码:
public void MyMethod()
{
Where = did + AllTheseWeirdThings(GetDeclared()); // ?
}
拥有类似“用“_”作为所有私有/受保护成员前缀的编码标准并没有帮助,因为实例成员仍然可以引用公共成员。
阅读此内容会更好:
public void MyMethod()
{
this.Where = this.did + base.AllTheseWeirdThings(this.GetDeclared()); // ?
}
有没有办法通过编译器选项、StyleCop 或类似的东西来强制执行此操作?