C# Inheritance: Static vs. Non-Static Field

前端 未结 3 1820
粉色の甜心
粉色の甜心 2021-01-23 14:51

I have a library base class (Controller) and three sub-classes that inherit from Controller (Sensor, Output, and Enviro

3条回答
  •  走了就别回头了
    2021-01-23 15:26

    Well, a private member won't be visible to your derived classes. You would need a protected member or property for that. Within the class, you can just refer to it as errorDescriptions or this.errorDescriptions.

    I'd be extremely wary of having a static, protected member variable that isn't thread safe and can be mutated by derived classes. That's just asking for trouble.

提交回复
热议问题