6
Answers

Accessing nonstatic member of outer class

rainplanet

rainplanet

21y
1.9k
1
Is there anyway to access nonstatic member (either method or variable) of outer class from nested (inner) class? Here is the example: public class outer { public string st = ""; public class inner { //here I need to access the st string without declaring st as static } } I could, of course, create a new object of type outer and refer the st variable using that object, like myOuter.st but then I think I just create a new instance of st. Please suggest. Thanks.

Answers (6)