C# Inheritance: Static vs. Non-Static Field

前端 未结 3 1821
粉色の甜心
粉色の甜心 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:43

    If you only need one instance of the dictionary than yes, change it to protected static. Also you should use ConcurrentDictionary instead for thread safety.

    In the derived classes you access the field using Controller.errorDescription

提交回复
热议问题