Can i access outer class objects in inner class

If I'm reading you correctly you want to access the objB property of class A within innerC WITHOUT passing it along.

This isn't how C# inner classes work, as described in this article: C# nested classes are like C++ nested classes, not Java inner classes

If you want to access A.objB from innerC then you are going to have to somehow pass class A to innerC.


You need to pass a reference of OuterClass to InnerClass, perhaps in the constructor, like:

public class OuterClass
{
    //OuterClass methods

    public class InnerClass
    {
        private OuterClass _outer;

        public InnerClass(OuterClass outer)
        {
            _outer = outer;
        }
    }
}

Then you can use that reference in all of your InnerClass methods.