Searching if value exists in a list of objects using Linq

后端 未结 9 1663
执念已碎
执念已碎 2020-12-04 05:17

Say I have a class Customer which has a property FirstName. Then I have a List.

Can LINQ be used to find if th

9条回答
  •  庸人自扰
    2020-12-04 06:04

    Another possibility

    if (list.Count(customer => customer.Firstname == "John") > 0) {
     //bla
    }
    

提交回复
热议问题