title: How to get frequency of elements from List in c#
body: <p>I am trying to get the frequency of elements stored in a list.</p>
  
  <p>I am storing the following ID's in my list</p>
  
  <pre><code>ID
  1
  2
  1
  3
  3
  4
  4
  4
  </code></pre>
  
  <p>I want the following output:</p>
  
  <pre><code>ID| Count
  1 | 2
  2 | 1
  3 | 2
  4 | 3
  </code></pre>
  
  <p>In java you can do the following way. </p>
  
  <pre><code>for (String temp : hashset) 
      {
      System.out.println(temp + ": " + Collections.frequency(list, temp));
      }
  </code></pre>
  
  <p>Source:<a href="http://www.mkyong.com/java/how-to-count-duplicated-items-in-java-list/" rel="nofollow">http://www.mkyong.com/java/how-to-count-duplicated-items-in-java-list/</a></p>
  
  <p>How to get the frequency count of a list in c#?  </p>
  
  <p>Thanks.</p>