6
Reply

Accessing nonstatic member of outer class

rainplanet

rainplanet

Oct 8 2003 10:06 PM
1.9k
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)