Yes, unlike the base class, you need to instantiate the inner class if you want to use it.
You can easily prove it to yourself by trying:
public class OuterClass
{
public InnerClass Ic { get; set; }
public class InnerClass
{
public InnerClass()
{
Foo = 42;
}
public int Foo { get; set; }
}
}
public class Program
{
static void Main()
{
Console.WriteLine(new OuterClass().Ic.Foo);
}
}
The above code throws a NullReferenceException because it is Icnot assigned.
Microsoft .