【发布时间】:2010-05-25 08:57:05
【问题描述】:
-
有人可以解释一下使用 Auto-Implemented Properties c# 背后的想法吗?
public class Customer { public int ID { get; set; } public string Name { get; set; } }我得到了使用私有字段属性的动机,因此我们可以确定如何访问私有字段。但是在这里 - 这就像从一开始就将字段定义为公开。没有?
将字段定义为“public const”或将其定义为具有 get-only 属性有区别吗?
【问题讨论】:
标签: c#