title: C# List of List initialization, { new List<int>() {1,2,3} } not working?
body: <p>I am trying to create a List of List of Integers, and I wanted to do it "inline" without using .Add, but it doesnt work, why?</p>
  
  <pre><code>// This is working
  List&lt;List&lt;int&gt;&gt; lists = new List&lt;List&lt;int&gt;&gt;();
  lists.Add(new List&lt;int&gt;() { 1, 2, 3 });
  lists.Add(new List&lt;int&gt;() { 4, 5, 6 });
  lists.Add(new List&lt;int&gt;() { 7, 8, 9 });
  
  // This compiles, no red, but is not working, the list stays empty
  List&lt;List&lt;int&gt;&gt; secondList = new List&lt;List&lt;int&gt;&gt;();
  {
      new List&lt;int&gt;() { 1, 2, 3 };
      new List&lt;int&gt;() { 4, 5, 6 };
      new List&lt;int&gt;() { 7, 8, 9 };
  };
  </code></pre>
  
  <p>Also, why the second example needs ; between the lists and not just "," like with a list of some type?</p>
  
  <p><strong>P.S. Solved</strong> I just realized that I had another issue, I wrote it as <code>List&lt;List&lt;int&gt;&gt; list = new List&lt;List&lt;int&gt;&gt;(); { ... };</code> in my code and that first semicolon shouldnt be there, a simple typo :D and it was asking for ; on the lines and was giving me errors when I was using ,</p>
  
  <p>Solution:</p>
  
  <pre><code>List&lt;List&lt;int&gt;&gt; secondList = new List&lt;List&lt;int&gt;&gt;
  {
      new List&lt;int&gt;() { 1, 2, 3 },
      new List&lt;int&gt;() { 4, 5, 6 },
      new List&lt;int&gt;() { 7, 8, 9 }
  };
  </code></pre>