Using .Contains() on a property in a list

前端 未结 8 586
庸人自扰
庸人自扰 2020-12-10 18:01

I have a List of Activity. In the Activity class is an ID property (a Guid for arguments sake). I want to check if this list has an Activity in it with a Guid I have. Rather

8条回答
  •  醉酒成梦
    2020-12-10 18:26

    to find all activity objects with the given GUID you can use:

    var results = ActivityList.FindAll(item => item.ID == GuidToCompare);
    

提交回复
热议问题