【发布时间】:2018-05-23 12:28:21
【问题描述】:
我有一个自定义列表 List。它返回所有项目。 Info的结构如下:
public class Info
{
public string Code { get; set; }
public string ClinicianDescription { get; set; }
}
我想从列表中排除任何 Info 对象,其中 Code 属性等于单独列表中的任何值。
在一个干净的方法之后,我尝试使用 .Except(),但我必须将列表转换为同一个对象,这似乎不正确。
到目前为止,我已经尝试过这样的事情:
List<int> ids = contactList;
var List<Info> test = info.RemoveAll(x => ids.Any(i => i == x.Code));
【问题讨论】:
-
为什么不使用循环?您是在寻找干净的方式还是困难的方式?
-
var List<Info> test... 会导致编译错误