title: Create a nested list from a flat list using Linq
body: <p>I have a list of strings like </p>
  
  <pre><code>A01,B01 ,A02, B12, C15, A12,  ... 
  </code></pre>
  
  <p>I want to unflatten the list into List of lists or dicitionary of lists such that<br>
  all strings starting with the same letter are group together (using linq)</p>
  
  <pre><code>A -&gt; A01 , A02 , Al2
  B -&gt; B01 , B12
  C -&gt; C15
  </code></pre>
  
  <p>or </p>
  
  <pre><code>    A -&gt; 01 , 02 , l2
      B -&gt; 01 , 12
      C -&gt; 15
  </code></pre>
  
  <p>For now I just iterate the list using for loop and add the values to the approp list from dictionary.</p>
  
  <p>(may not be right!)</p>
  
  <pre><code>   Dictionary&lt;string, List&lt;string&gt;&gt; dict = new Dictionary&lt;string, List&lt;string&gt;&gt;();
  
           foreach( string str in stringList)
           {
              string key = str.Substring(0,1);
              if (!dict.ContainsKey(key)){
                  dict[key] = new List&lt;string&gt;();
              }
  
              dict[key].Add(str);
           }
  </code></pre>
  
  <p><strong>Edit</strong> :<br>
   Oh sorry i forgot to add  this ,
  I have a list of Category objs , and these are Category names.<br>
  I need to retrieve something like <code>Dictionary&lt;string, List&lt;Category&gt;&gt;</code> , going forward i want to bind this to a <a href="http://www.w3schools.com/html/tryit.asp?filename=tryhtml_lists2" rel="nofollow">nested list</a> . (asp.net/ mvc )</p>
  
  <p>Is there a better way to do the same using Linq?</p>