Collections

  • Thread starter Thread starter James T.
  • Start date Start date
J

James T.

Hello!

I am using KeyedCollection to store data. Now I would like to get the last
item in that colletion... Could someone please provide an example how I can
do that?

James
 
You can use an Enumerator (via the GetEnumerator() method of the Collection)
to loop through the Collection, and when the MoveNext() method of the
Enumerator turns false, the item before that was the item. So, just assign
the items to a variable during the loop (using IEnumerator.Current), and the
one in the variable at the end of the loop is the last item in the
Collection. I'm not sure what sort of order they may be stored in, however.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top