Sim*_*mon 1 .net field properties naming-conventions
在为属性执行支持字段时,常见的命名方案是什么?
编辑:提出特定于.net的问题
我通常使用属性名称本身,驼峰式和前缀下划线:
private int _someProperty;
public int SomeProperty
{
get { return _someProperty; }
set { _someProperty = value; }
}
Run Code Online (Sandbox Code Playgroud)
如果您正在使用C#并且该属性只是一个简单的字段访问器,那么您可以使用自动实现的属性,命名问题就会消失:
public string SomeOtherProperty { get; set; }
Run Code Online (Sandbox Code Playgroud)