使用linq或lambda比较两个通用列表 [英] Compare two generic List using linq or lambda

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

问题描述

class myFile{

public filename
public filedate

}

List<myfile> source = new List<<myfile>();
add files..
<list><myfile> target = new List<myfile>();
add files..</myfile></myfile></list></myfile></myfile>



比较列表并返回
1)源列表独有的文件列表
2)目标列表特有的文件列表
3)目标日期不同的源文件列表

我可以使用三个foreach语句来做到这一点
但是使用linq或Lambda表达式有一种简单的方法吗?



Compare the list and return
1) List of files unique to source list
2) List of files unique to target list
3) List of source files where target date is diffrent

I can do this with three foreach statements
but is there an easy way using linq or Lambda expression?

推荐答案

看看LINQ
Have a look at the LINQ Except[^] method.


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

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