0

How do you find the index of an object in a binding list? Below is my code:

public class Object
{
     public string Name { get; set; }
     public int id { get; set; }
}
BindingList<Object> objectList = new BindingList<Object>();

I want to do something like var int = objectList.FindIndex(a => a.Name == "Text"); I've seen the use of SingleOrDefault from LINQ to find the object itself, but how can I find the index?

OGP99
  • 149
  • 9
  • I'm currently using `objectList.ToList().FindIndex(a => a.Name == object.Name)`, and I'm wondering if there's a more succinct answer. – OGP99 Jul 23 '21 at 15:27
  • How could it be shorter than 1 method name with 1 parameter ? – Franck Jul 23 '21 at 15:29

0 Answers0