Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个场景,我需要从对象列表中选择某些对象
例如
List<MyObjects> selectedObject = myObjectList.Where(o => o.LastName in (checkedObj.LastName where checkedObj.IsSelected == true )
如何使用 lambda 表达式完成此操作?
使用Any将是一种解决方案:
Any
List<MyObjects> selectedObject = myObjectList.Where(o => checkedObjList.Any(c => c.LastName == o.LastName && c.IsSelected))
(假设你有一个checkedObjList上面checkedObj的内容。)
checkedObjList
checkedObj