Accessing Nested Class Information

So in my A class, I initialize an instance of class B. As part of class B’s constructor, it initializes an instance of class C.

By using Debug.Log statements, I know that both B and C are being correctly initialized, however when I try to do B.C from within class A, I get a null reference exception, “Object Reference not set to an instance of an object”.

Code is as follows:

public class A : Monobehavior
    {
        B b;
        private void Awake()
            {
                b=new B("B_Name");
                Debug.Log(b.c.CName);
            //Null Reference Exception error happens on the above line of code
            }
    }
    
    public class B
    {
        public C c;
        public string BName;
        public B(string name)
            {
                BName=name;
                c=new C("C_Name");
            }
    }
    
    public class C
    {
        public string CName;
        public C("name")
            {
                CName=name;
            }
    }

Nvm, solved. I was doing “C c = new C” instead of just “c=new C”. Whoops!