What fields can a nested class access of the class it's nested in?

后端 未结 3 1797
一个人的身影
一个人的身影 2021-01-25 22:58

I have a web service in C# and would like to have a nested inner class, that abstracts away the session collection, something like this:


public class Service          


        
3条回答
  •  伪装坚强ぢ
    2021-01-26 00:01

    Nested classes in C# aren't like (non-static) inner classes in Java. There is no implicit reference to an instance of the containing class - so you can't use any instance members of the containing class without an explicit reference.

    However, you do have access to all private members of the containing class - with a suitable reference for instance members.

提交回复
热议问题