title: Linq: Converting flat structure to hierarchical
body: <p>What is the easiest and somewhat efficient way to convert a flat structure:</p>
  
  <pre><code>object[][] rawData = new object[][] 
  { 
    { "A1", "B1", "C1" }, 
    { "A1", "B1", "C2" },
    { "A2", "B2", "C3" }, 
    { "A2", "B2", "C4" }
    // .. more 
  };
  </code></pre>
  
  <p>into a hierarchical structure:</p>
  
  <pre><code>class X
  {
    public X () 
    {
      Cs = new List&lt;string&gt;();
    }
    public string A { get; set; }
    public string B { get; set; }
    public List&lt;string&gt; Cs { get; private set; }
  }
  </code></pre>
  
  <p>the result should look like this</p>
  
  <pre><code>// pseudo code which describes structure:
  result =
  {
    new X() { A = "A1", B = "B1", Cs = { "C1", "C2" } },
    new X() { A = "A2", B = "B2", Cs = { "C3", "C4" } }
  }
  </code></pre>
  
  <p>Preferably using Linq extension methods. Target class <code>X</code> could be changed (eg. a public setter for the List), only if not possible / useful as it is now.</p>