title: Grouping KeyValue pairs to Dictionary
body: <p>I have the following code :</p>
  
  <pre><code>using System.Collections.Generic;
  
  
  public class Test
  {
      static void Main()
      {
  
          var items = new List&lt;KeyValuePair&lt;int, User&gt;&gt;
                          {
                              new KeyValuePair&lt;int, User&gt;(1, new User {FirstName = "Name1"}),
                              new KeyValuePair&lt;int, User&gt;(1, new User {FirstName = "Name2"}),
                              new KeyValuePair&lt;int, User&gt;(2, new User {FirstName = "Name3"}),
                              new KeyValuePair&lt;int, User&gt;(2, new User {FirstName = "Name4"})
                          };
  
      }
  }
  public class User
  {
      public string FirstName { get; set; }
  }
  </code></pre>
  
  <p>Above as you can see there are multiple users for same key . Now I want to group them and convert the list object to dictionary in which the Key will be the same(1,2 as shown above) but the value will be the collection.Like this:</p>
  
  <pre><code> var outputNeed = new Dictionary&lt;int, Collection&lt;User&gt;&gt;();
          //Output:
          //1,Collection&lt;User&gt;
          //2,Collection&lt;User&gt;
  </code></pre>
  
  <p>i.e they are grouped now.</p>
  
  <p>How can I achieve that ?</p>