Sawper hayabosa
Sawper hayabosa

Reputation: 60

How to find index of an item in a List<> where two or more property need to be check

How to find index of an item in a List<> where two or more property need to be checked?

This works:

int index = myList.FindIndex(a => a.Prop == oProp);

This doesn't work:

int index = myList.FindIndex(a => a.Prop1 == oProp1 && a => a.Prop2 == oProp2);

Upvotes: 0

Views: 147

Answers (1)

Wjdavis5
Wjdavis5

Reputation: 4151

All you need to do is:

int index = myList.FindIndex(a => a.Prop1 == oProp1 && a.Prop2 == oProp2);

Upvotes: 2

Related Questions