How do I know if I'm iterating on the last item of the collection?
- by Camilo Martin
I want to do something different on the last KeyValuePair of the Dictionary I'm iterating on.
For Each item In collection
If ItsTheLastItem
DoX()
Else
DoY()
End If
Next
Is this possible?
Edit: As Jon correctly remarks, Dictionaries are not the kind of thing that's sorted, so I should mention that I only want to do this when displaying results to the user, and it doesn't matter if later on the last item is different.
In another note, I'll use my own answer but I'll accept the most upvoted one after I check back in some hours.