title: Find datarows with the same id in C#
body: <p>It is my first time working with Datarows or tabular data. Considering I have a simple table with two columns, one contains the ID and the other contains a name string. What I need to do is find two Datarows with the same ID, and pass these two rows to another function, lets call it <code>HandleTheDuplicates</code>. </p>
  
  <p>At the moment I am trying store the previous ID in another variable and check if this matches to the current ID and then add it to a list of type DataRow. </p>
  
  <pre><code>List&lt;DataRow&gt; RowList = new List&lt;DataRow&gt;();
  int previous = 0 ;
  foreach (DataRow rowToMatch in importSetOfTables.Tables["MyTable"].Rows)
  {
       int rowID = Convert.ToInt32(rowToMatch["ID"]);                               
       if (previous == rowID)
       {
            RowList.Add(rowToMatch);
       }
       else
       {
            RowList.Clear();
       }
       previous = rowID;
  
       if(RowList.Count &gt; 1) //in case of a match
       {
            HandleTheDuplicates(RowList);
       }
  }
  </code></pre>
  
  <p>I don't know if this is the right way of doing something like this or if there could be something more simpler. </p>