Reputation: 19356
I have a class Person with two properties, genre and IsDead. I want to know if all men are death or not, in a list.
I am using this way:
if(myList.Where(x=> x.Genre == "MALE").All(x=> x.IsDeath == true));
But I don't know if there are other better option, instead of using a where and set all the properties in the All, Any... function.
Thanks.
Upvotes: 0
Views: 87
Reputation: 1279
You can also do.
if(!myList.Any(x => x.Genre == "MALE" && !x.IsDeath))
Upvotes: 2