Virtual/Abstract fields in C#

前端 未结 9 1214
逝去的感伤
逝去的感伤 2020-12-16 10:19

Is it possible to have a virtual/abstract field in a C# class? If so, how is it done?

9条回答
  •  星月不相逢
    2020-12-16 10:45

    Fields are storage locations in a class - you cannot "override" them or make the virtual.

    Properties, on the other hand can be made both virtual or abstract. Properties are simply syntactic sugar around get/set methods, which do the work of retrieving or setting the property value.

提交回复
热议问题