Virtual/Abstract fields in C#

前端 未结 9 1172
逝去的感伤
逝去的感伤 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:47

    A Virtual/Abstract field? No. Fields are just there to hold data. There's nothing to implement.

    You can define a Virtual/Abstract Property though.

    0 讨论(0)
  • 2020-12-16 10:47

    You can however have virtual or abstract properties:

    public abstract string ModelName { get; set; }
    
    0 讨论(0)
  • 2020-12-16 10:48

    No. You'd have to use a property to accomplish what you seem to what to do.

    0 讨论(0)
提交回复
热议问题