Can we create an object of the inner class in the constructor of the outer class into C#? Is it legal?
public class Outer
{
public Inner InnerObj {get; set; }
public Outer()
{
Inner inner = new Inner();
}
public Outer(Inner inner)
{
InnerObj = inner;
}
public class Inner
{
}
}
for Java I take the reference from below link: Can we create an object of the inner class in the constructor of the outer class?
My colleague said this is not possible in C# and it's totally illegal. Please guide me.