linq to sql - How to Compare Two Datatable and get common records in other DataTable in C#? -


i have 2 datatable 2 columns in each table. now, want compare these 2 datatable , matching rows in third datatable in c#.

eg:

datatablea cola1   cola2  1      sampletext1  2      sampletext2  4      sampletext4  datatableb colb1   colb2  1      sampletext1  2      sampletext2  3      sampletext3  datatablec colc1  colc2  1      sampletext1  2      sampletext2 

i have tried using loop slows down. other alternative.

not sure matching criteria is. below might helpful.

refer this

public static datatable comparetwodatatable(datatable dt1, datatable dt2) {    dt1.merge(dt2);   datatable d3 = dt2.getchanges();   return d3; } 

Comments