我希望linq c#查询比较两个表并列出表1中不匹配的记录
var Unmatched = new List<Row>();
foreach (var row in Table1)
{
if (!Table2.Rows.Contain(row))
Unmatched.Add(row);
}
诸如此类?它将仅检查未匹配的表1到表2。它不会检查Table2到Table1。
我们需要更多详细信息。
代码的最后一行比较两个列表的元素,并带有!仅包含保留第一个列表中不匹配的元素,并将其添加到新的Unmathced列表中:
List<string> table_1 = new List<string>() { "panos", "mitsos", "alex", "niki" };
List<string> table_2 = new List<string>() { "panos", "mitsos", "alexandros", "maria" };
List<string> UnmatchedList= new List<string>();
UnmatchedList = table_1.Where(x => !table_2.Contains(x)).ToList();