可能重复:
Differences between Private Fields and Private Properties初始化对象的私有财产
比方说,我有一个拥有私人财产MyProp一个MyClass类。 有什么
public class MyClass
{
private int MyProp { get; set; }
}
和
public class MyClass
{
private int MyProp = 0;
}
更棒的使用之间的区别? 谢谢。
第一个是一个属性。第二个是一个领域。 – DOK 2012-01-10 21:12:07
重复相同类型的问题... http://stackoverflow.com/questions/1568091/why-use-getters-and-setters – Lloyd 2012-01-10 21:12:18
http://stackoverflow.com/questions/653536/difference-between-财产和场中的c - 锐利 http://csharpindepth.com/articles/chapter8/propertiesmatter.aspx – 2012-01-10 21:14:04