LINQ - 比较两个列表 [英] LINQ - compare two lists

查看:130
本文介绍了LINQ - 比较两个列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个列表:

List<int> listA     
List<int> listB

如何检查使用LINQ如果在为listA 存在wchich deosn't的元素存在于数组listB ?我可以使用的foreach 循环,但我想知道如果我能做到这一点使用LINQ

How to check using LINQ if in the listA exists an element wchich deosn't exists in the listB ? I can use the foreach loop but I'm wondering if I can do this using LINQ

推荐答案

listA.Except(数组listB)会给你所有为listA不在数组listB的项目

listA.Except(listB) will give you all of the items in listA that are not in listB

这篇关于LINQ - 比较两个列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆