title: How Can I create objects of List<MyClass> dynamically?
body: <p>How I can create Objects of MyClass Dynamically? I have nested lists, I will get the count of nested lists from my DataTable, so I don't know how many objects I need.
  I am working inside loop.</p>
  
  <p>Can I please get some help with example?</p>
  
  <pre><code>for (int i = 0; i &lt; table.Rows.Count; i++)
  {
  List&lt;MyClass&gt; names[i] = new List&lt;Checklists&gt;();
  }
  </code></pre>
  
  <p>So I will get:</p>
  
  <pre><code>names0
  names1
  names2
  ......n
  </code></pre>
  
  <p>And then I will Add elements like </p>
  
  <pre><code>name0.Add(new MyClass(...))
  name1.Add(new MyClass(...))
  name2.Add(new MyClass(...))
  </code></pre>
  
  <p>.........</p>
  
  <p>I read a few questions on StackOverFlow, but they are not helping in my case, as they are not about List. Like <a href="https://stackoverflow.com/questions/10930705/creating-objects-dynamically-in-loop">Creating objects dynamically in loop</a></p>