Scope of Nested Classes

Posted by Vaccano on Stack Overflow See other posts from Stack Overflow or by Vaccano
Published on 2010-06-03T20:41:49Z Indexed on 2010/06/03 20:44 UTC
Read the original article Hit count: 284

Filed under:

If I have a nested class, does anything from the owning class exist in the owned class?

for example:

public class OwningClass 
{

    int randomVariable = 1;

    public void MakingMethod()
    {
        OwnedClass owned = new OwnedClass();
        owned.SomeMethod();
    }

    private class OwnedClass
    {
        public void SomeMethod()
        {
            // Is anything from OwningClass available here?
        }

    }

}

© Stack Overflow or respective owner

Related posts about c#