本文介紹了C# - 合并兩個重復行的數據表的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我可以找到很多關于合并兩個 DataTables 和刪除重復行的信息,但我需要相反的.
I can find lots of information about merging two DataTables and dropping duplicate rows, but I need the opposite.
我需要知道是否有人有一種簡單的方法來合并兩個 DataTable,其中合并的結果是一個 DataTable,其中只有兩個表中都存在行.
I need to know if anyone has an easy way to merge two DataTables where the result of the merge is a DataTable with only rows that exist in both tables.
推薦答案
像這樣:
var intersection = table1.AsEnumerable()
.Intersect(table2.AsEnumerable(), DataRowComparer.Default);
DataRowComparer
按列值比較行.
這篇關于C# - 合并兩個重復行的數據表的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!