Class declared inside of another class in C#

前端 未结 7 1137
庸人自扰
庸人自扰 2021-02-02 06:12

I am working on some legacy code and have come across something that I\'m not sure of. We have a class y that is declared inside of another class x.

相关标签:
7条回答
  • 2021-02-02 06:48

    This code is fine for the exact reason that you have given - "class y is only ever used inside of class x". Those are nested types and one of the guidelines for using them is that nested types should be tightly coupled to their declaring type and must not be useful as a general purpose type. That way the nested class is inacessible to other classes, but still allows you to follow object oriented principles.

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