【发布时间】:2016-12-10 14:46:21
【问题描述】:
我的理解是,当我在 c# 中创建一个速记属性时,它会在编译后转换为为其创建的字段。
class Hello {
public bool Hi { set ; get ; }
}
我的问题是如果速记属性是虚拟的然后被覆盖会发生什么:
class Hello {
virtual public bool Hi { set ; get ; }
}
//The class and the property can't have the same name
//class Hi : Hello {
class Bonjour : Hello {
override public bool Hi {
set { }
get { return true ; }
}
}
我已经完全覆盖了虚拟属性。在编译类 Hi 时,这是否仍会生成一个我将无法再访问的字段?
谢谢。
【问题讨论】:
标签: c# properties cil accessor mutators