title: Best shortest way to set value in c# class
body: <p>Check the code bellow. Here i want to set value of <code>Root</code> class and also with all its child list value. I already tried like bellow but i was able to do it for <code>Root</code> but how can i set value for all inside child class?</p>
  
  <p>Model Class:</p>
  
  <pre><code>namespace MyProject.ViewModels
  {
  
      public class Child3
      {
          public int Id { get; set; }
          public string text { get; set; }
      }
      public class Child2
      {
          public int Id { get; set; }
          public string text { get; set; }
          public List&lt;Child3&gt; children { get; set; }
      }
      public class Child
      {
          public int Id { get; set; }
          public string text { get; set; }
          public List&lt;Child2&gt; children { get; set; }
      }
      public class Root
      {
          public int Id { get; set; }
          public string text { get; set; }
          public List&lt;Child&gt; children { get; set; }
      }
  
  }
  </code></pre>
  
  <p>Trying to set value:</p>
  
  <pre><code>var root = new List&lt;Root&gt;();
  
  
      root.Add(new Root
      {
          Id = 1,
          text = "foo",
          children = new List&lt;Child&gt;()
          {
              //i am not getting idea from here.
          },
      }); 
  </code></pre>