Retrieve index of a List<> item based in C# using Linq -
it pretty simple question, have list of object has field named "id".
how can retrieve index of object in list if know id?
example:
custom_objects test = new custom_objects{id=50}; list<custom_objects> list = new list<custom_objects>(); list.add(test); i retrieve index of object id = 50 in list, 0 in example.
var index = list.findindex(x=>x.id==50);
Comments
Post a Comment