title: How to get difference between two DataTables
body: <p>I have these two datatables and I want to get the difference between them. Here is an example:</p>
  
  <pre><code>Table1
  -------------------------
  ID  |   Name 
  --------------------------
   1  |  A
   2  |  B
   3  |  C
  --------------------------
  
  Table2
  -------------------------
  ID  |   Name 
  --------------------------
   1  |  A
   2  |  B
  --------------------------
  </code></pre>
  
  <p>I just want the result as data which is in table1 and not in table2 (table1-table2)</p>
  
  <pre><code>ResultTable
  -------------------------
  ID  |   Name 
  --------------------------
   3  |  C
  --------------------------
  </code></pre>
  
  <p>I tried to use these two similar solutions via Linq, but it always return table1 and not table1-table2. Here is first solution:</p>
  
  <pre><code>DataTable table1= ds.Tables["table1"];
  DataTable table2= ds.Tables["table2"];
  var diff= table1.AsEnumerable().Except(table2.AsEnumerable(),DataRowComparer.Default);
  </code></pre>
  
  <p>Second solution:</p>
  
  <pre><code>var dtOne = table1.AsEnumerable();
  var dtTwo = table2.AsEnumerable();
  var difference = dtOne.Except(dtTwo);
  </code></pre>
  
  <p>So, where is the mistake? Thank you a lot for all your answers. :)</p>