If I have a list of items, and say "ID" is unique, but not necessarily sequential, then Is not the way to find the last unit in either a list or an IEnumerable say?
So I can have a list of people, and they each have an ID and they are sorting in one order. I do not know what I get is the list and id of the person.
Now I need to bring the last person in the ID that was provided to me.
Is there a good LINQ method to do this or do I only search for records and get the last time in the eTech?
Edit I found, this is the best way? I think you need it
items.TakeWhile (X => x.id! = ID) .LastOrDefault ();
Numeric. Take while the method specifies elements from a sequence until a specified condition is true, and then leaves the remaining elements.
default from it.
No comments:
Post a Comment