可能重复:
C# .NET 3.5+ 中属性和字段之间的区别
示例代码:
public struct State
{
private readonly byte state;
private State (byte pState)
{
state = pState;
}
// property...
public static State StateOne
{
get
{
return new State (1);
}
}
// or...
public static readonly State StateOne = new State (1);
}
我应该使用属性还是字段?在此示例中,性能无关紧要。