Link to home
Start Free TrialLog in
Avatar of SiJP
SiJP

asked on

FindLast in vb.net Generics List

I have a problem understanding how to retrieve the last item in a List.

This is the List:

Object.ListOfItems As System.Collections.Generic.List(Of MyItem)

And this is where I get stuck:

Dim item as MyItem = Object.ListOfItems.FindLast( ...... <-- what should go here?  If this list contains 20 items, I want the 20th item!!

TIA
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Dim item as MyItem = Object.ListOfItems.FindLast(Object.ListOfItems.Count - 1)
ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Find Last is used for a predicate search
e.g. if you are searching in the list of generics containing 20 and you get 10 records from your search it will return you the last from the searched results
http://msdn.microsoft.com/en-us/library/5kthb929.aspx

to find the last from the list use the method suggested by wayne
Avatar of SiJP
SiJP

ASKER

Wood .. Trees ..  :D
Avatar of SiJP

ASKER

Thanks Wayne & ragi .. RAPID responses!