Class declared inside of another class in C#

前端 未结 7 1130
庸人自扰
庸人自扰 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:44

    You create an inner class because it is only ever used within the scope of class x and it logically fits in the factoring/architecture of class x.

    Class y might also be privy to implementation details of class x that are not meant to be known to the public.

提交回复
热议问题