减去从另一个泛型列表 [英] Subtract a generic list from another
本文介绍了减去从另一个泛型列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
喜的朋友,我很坚持,
我想从另一个列表中删除firmIDs列表。
我真的不明白LINQ,但我敢肯定我需要使用它
列表<公司>商行= GetBusinessDevelopmentFirms(数据库);
名单,LT;公司> trackedFirms = GetAllCLIFirmsBeingTrackedByUser();
VAR的结果= firms.Contains(I => trackedFirms.Contains(i.FirmID));
最后一行不起作用,系统提示未知方法包含(?),即使我已经把使用System.Linq的;在类的顶部。
我的想法是从所有企业的名单中删除跟踪公司的名单,找到未跟踪的公司。
我希望这是有道理的。
解决方案
VAR结果= firms.Except(trackedFirms); //返回所有的企业,除了那些在trackedFirms
Hi friends I am really stuck,
I am trying remove a list of firmIDs from one list from another. I don't really understand linq but I am pretty sure I need to use it.
List<Firm> firms = GetBusinessDevelopmentFirms(database);
List<Firm> trackedFirms = GetAllCLIFirmsBeingTrackedByUser();
var result = firms.Contains(i => trackedFirms.Contains(i.FirmID));
The last line doesn't work and the system says "unknown method Contains(?)" even though I have put "using System.Linq;" At the top of the class.
My idea was to remove a list of tracked firms from a list of all firms to find the untracked firms.
I hope this makes sense.
解决方案
var result = firms.Except(trackedFirms); // returns all the firms except those in trackedFirms
这篇关于减去从另一个泛型列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文