Reputation: 60
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
Reputation: 4151
All you need to do is:
int index = myList.FindIndex(a => a.Prop1 == oProp1 && a.Prop2 == oProp2);
Upvotes: 2