linq查询表单 [英] linq query form

查看:53
本文介绍了linq查询表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码如何转换为linq或谓词表达式:

How can be the following code converted to linq or predicate expression:

List<int> list1 = new List<int> {1,2,3,4,5};
List<int> list2= new List<int> {2,3,4,5,6,7};
foreach (int int1 in list1)
 list2.Remove(int1);

推荐答案

您可以执行以下操作:

list1.ForEach( x => { list2.Remove(x); } );

这篇关于linq查询表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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