如何比较2 List< string>对象以从List< string>获取缺少的值 [英] How to compare 2 List<string> objects to get the missing value from the List<string>
本文介绍了如何比较2 List< string>对象以从List< string>获取缺少的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用"NOT IN"获取丢失的数据,并将其添加到"foo"列表中.
How do I use the "NOT IN" to get the missing data, to be added to "foo" List.
var accessories = new List<string>();
var foo = new List<string>();
accessories.Add("Engine");
accessories.Add("Tranny");
accessories.Add("Drivetrain");
accessories.Add("Power Window");
foo.Add("Engine");
foo.Add("Tranny");
foo.Add("Power Window");
foreach(var v in foo.Where(x => x??).???)
{
foo.Add(v); //Add the missing "Drivetrain" to it...
}
推荐答案
使用从MSDN:
除产生两个序列的集合差异.
Except Produces the set difference of two sequences.
这篇关于如何比较2 List< string>对象以从List< string>获取缺少的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文