Nested type problem
问题 I just tried to create this simple implementation: class Test { private int abc = 0; public class TestClass { private void changeABC() { abc = 123; } } } If I compile it, it will complain: Cannot access a non-static member of outer type 'A.Test' via nested type 'B.Test.TestClass' I dont like the solution of setting: static int abc = 0; Is there any other solution for this? 回答1: You are probably coming from a Java background where this code would work as expected. In C#, nested types are