Inner class and Outer class in c#

前端 未结 4 2010
天命终不由人
天命终不由人 2021-01-05 19:25

how to implement inner outer classes in c#

i have two nested classes

like

class Outer
{
    int TestVariable = 0;
    class Inner
    {
              


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-05 20:11

    Short answer: No,

    You will somehow need to inject the TestVariable into your Inner class. Making your testVariable could potentially lead to undesired behaviour. My sugestion would be to inject it via the constructor.

提交回复
热议问题