title: Grouping Linq Issue, can't get it right
body: <pre><code>public class Emp
  {
       public int EmpId { get; set; }
       public string Type { get; set; }
       public List&lt;string&gt; Email { get; set; }             
  }
  </code></pre>
  
  <p>I fetch data from database and put it in a list </p>
  
  <pre><code>List&lt;Emp&gt; employees= new List&lt;Emp&gt;();
  // fill the list here via DB call
  </code></pre>
  
  <p>The list would have, please also note that Type field would always be same for same user but email would be different</p>
  
  <pre><code>employees[0] = new Emp{ EmpId = 1, Type = "User", Email = "one@test.com" }; 
  employees[1] = new Emp{ EmpId = 1, Type= "User", Email = "two@test.com"     }; 
  
  employees[2] = new Emp{ EmpId = 2, Type = "Test", Email = "three@test.com" }; 
  employees[3] = new Emp{ EmpId = 2, Type= "Test", Email = "four@test.com"}; 
  
  employees[4] = new Emp{ EmpId = 3, Type = "Test", Email = "five@test.com" }; 
  employees[5] = new Emp{ EmpId = 3, Type= "Test", Email = "six@test.com"}; 
  
  employees[6] = new Emp{ EmpId = 4, Type= "User", Email = "seven@test.com"}; 
  </code></pre>
  
  <p>I'm trying to group Emp based on their EmpId
  so the result should be a new list</p>
  
  <p><strong>Expected Result</strong></p>
  
  <pre><code>Result = new Emp{ EmpId = 1, Type = "User", Email = "one@test.com", "two@test.com" }; 
       new Emp{ EmpId = 2, Type = "Test", Email = "three@test.com", "four@test.com" }; 
       new Emp{ EmpId = 3, Type = "Test", Email = "five@test.com", "six@test.com" }; 
       new Emp{ EmpId = 4, Type = "User", Email = ""seven@test.com" };
  </code></pre>
  
  <p>//This is what I have done so far
  // Please let me know if this is incorrect</p>
  
  <pre><code>var result = from emp in employees
                group emp.Email by new { emp.EmpId, emp.Type } into g
                select new { Key = g.Key, Type = g.Key.Type, Emails = g.ToList() };
  </code></pre>
  
  <p>// My problem comes here when I loop this result</p>
  
  <pre><code>foreach (var r in result)
  {
  Console.WriteLine(r.Key.EmpId + "--" + r.Key.Type);
  
  //This is where I need to get all emails of the Employee which I grouped 
  // iF I IMPLEMENT FOREACH
      foreach (var e in r.Emails)
      {
          //?? WHAT i DO HERE 
          //e.?? to get email
      }
  
  // OR  iF I IMPLEMENT FOR LOOP
  
      for(int i = 0 ; i&lt; r.Emails.Count; i++)
      {
          Console.WriteLine("Inner Loop" + "--" + r.Key.EmpId + "--" + r.Key.Type + "--" + r.Emails[0].ToString()); // r.Emails[0].ToString() prints out System.Collections.Generic.List '1[System.String]
      }
  } 
  </code></pre>
  
  <p>Please let me know if I mad eany mistake or there's other way to do this.
  <strong>All I need is Group employees based on EmpID and also have their Type but grouped Emails.</strong></p>