title: I want to count number of each element in list using linq in c#
body: <p>I write this code and its working correctly. Is there any better way to do this using <code>LINQ</code> to reduce time complexity.</p>
  
  <pre><code>List&lt;int&gt; list = new List&lt;int&gt;() { 1, 2, 3, 1, 2, 3, 1, 2, 7, 2, 2 };
  
  var distinctList = list.Distinct();
  
  var listWithCount = distinctList.Select(q=&gt;new { num=q, count = list.Count(number=&gt;number==q) });
  
  foreach(var number in listWithCount)
  {
      Console.WriteLine("num : " + number.num + "  count : " + number.count);
  }
  </code></pre>