Using Inner classes in C#

前端 未结 9 1924
粉色の甜心
粉色の甜心 2020-12-02 18:40

What are the best practices regarding the use and structure of inner classes in C#.

For instance if I have a very large base class and two large inner classes should

9条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-02 19:35

    Generally inner classes should be private and usable only by the class that contains them. If they inner classes are very large that would suggest they should be their own classes.

    Usually when you've got a big inner class it's because the inner class is tightly coupled to it's containing class and needs access to its private methods.

提交回复
热议问题