title: Count distinct values of a column in dataGridView using linq in .NET
body: <p>I need to count and present distinct/unique values in a dataGridView. 
  I want to present it like this, and this code works just fine with lists. </p>
  
  <pre><code>        List&lt;string&gt; aryIDs = new List&lt;string&gt;();
          aryIDs.Add("1234");
          aryIDs.Add("4321");
          aryIDs.Add("3214");
          aryIDs.Add("1234");
          aryIDs.Add("4321");
          aryIDs.Add("1234");
  
          var result= aryIDs.GroupBy(id =&gt; id).OrderByDescending(id =&gt; id.Count()).Select(g =&gt; new { Id = g.Key, Count = g.Count() });
  </code></pre>
  
  <p>But when I try to use the same approach on a column in dataGridView I get an error saying that groupBy cannot be used on my dataGridView. </p>
  
  <pre><code>        DataGridView dataGridView1= new DataGridView();
          dataGridView1.Columns.Add("nr", "nr");
          string[] row1 = new string[] { "1234" };
          string[] row2 = new string[] { "4321" };
          string[] row3 = new string[] { "3214" };
          string[] row4 = new string[] { "1234" };
          string[] row5 = new string[] { "4321" };
          string[] row6 = new string[] { "1234" };
  
          object[] rows = new object[] { row1, row2, row3, row4, row5, row6 };
  
          foreach (string[] rowArray in rows)
          {
              dataGridView1.Rows.Add(rowArray);
          }
  
          var result = dataGridView1.GroupBy(id =&gt; id).OrderByDescending(id =&gt; id.Count()).Select(g =&gt; new { Id = g.Key, Count = g.Count() });
  </code></pre>
  
  <p>So my question is, how do I adapt this linq syntax to work with a column in dataGridView? If possible, i dont want to use lists at all. </p>