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
Visual Basic ClassicC#

Avatar of undefined
Last Comment
SiJP

8/22/2022 - Mon
Wayne Taylor (webtubbs)

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

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Anurag Thakur

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
SiJP

ASKER
Wood .. Trees ..  :D
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
SiJP

ASKER
Thanks Wayne & ragi .. RAPID responses!