If you just want to know if there is at least one of them, you can use Enumerable.Any
:
bool atLeastOneCustomerWithMiddleName = Customers.Any(c => c.HasMiddleName);
If you want to know the first suitable client, you can use Enumerable.First
or Enumerable.FirstOrDefault
to find the first client with MiddleName==true
:
var customer = Customers.FirstOrDefault(c => c.HasMiddleName); if(customer != null) {
First
throws an InvalidOperationException if the source sequence is empty, and FirstOrDefault
returns null
if there is no match.
source share