<分区>
我原以为对 this.GetProp
的赋值会在编译时失败,因为该属性不支持 set
。这段代码用 VS2015 和 NET461 编译得很好。
public class Example
{
public Example(string val)
{
this.GetProp = val;
this.GetSetProp = val;
}
public string GetProp { get; }
public string GetSetProp { get; set; }
}
是否有对自动属性中支持字段的隐含私有(private)访问?