c# Public Nested Classes or Better Option?

后端 未结 8 628
青春惊慌失措
青春惊慌失措 2020-12-03 05:49

I have a control circuit which has multiple settings and may have any number of sensors attached to it (each with it\'s own set of settings). These sensors may only be used

8条回答
  •  自闭症患者
    2020-12-03 06:23

    I like nested classes in cases like this because it shows the relationship. If you do not want users of the outer class to be able to create items of the inner class separately from the outer class, you can always hide the constructors and use factory methods in the outer class to create elements of the inner class. I use this structure a lot.

提交回复
热议问题