C# do nested classes need to be instantiated?

Posted by JL on Stack Overflow See other posts from Stack Overflow or by JL
Published on 2010-05-17T22:13:14Z Indexed on 2010/05/17 22:20 UTC
Read the original article Hit count: 102

Filed under:

In the following scenario:

public class outerclass
{
   public innerClass Ic
     {get;set}

   public class innerClass
   {

   }
}

Do you need to instantiate the inner class property before assigning values to it, like this?

public class outerclass
{
   public outerclass()
     {
        this.Ic = new innerClass(); 
     }

   public innerClass Ic
     {get;set}

   public class innerClass
   {

   }
}

© Stack Overflow or respective owner

Related posts about c#