Hi There.
I have a SortedList collection that I add objects of a custom class
to. Rather then explain my app, my question is pretty general so....
Using a simple clsDog:
***************************
clsDog boomer = new clsDog();
clsDog spot = new clsDog();
clsDog benjy = new clsDog();
SortedList listPets = new SortedList();
listPets.Add ("boomer", boomer);
listPets.Add ("spot", spot);
listPets.Add ("benjy", benjy);
****************************
So, at this point my list has sorted itself and I can verify the
indexes are good (ie, benjy is at index 0, boomer is at 1, spot is at
2).
I realize that the .GetByIndex method has an "object" return type. So,
my understanding is that if I want to return the object at the 1st
index I'd use:
thisDog = (clsDog)listPets.GetByIndex(1);
Unfortunately, this theory is not working out as it appears no matter
the Index that I ask for the collection will always seem to return the
last object I touched (in the above example object benjy is ALWAYS
returned, even though I return the proper key for the 1st index of
"boomer").
I understand that there might be other issues, but after wasting much
of the afternoon I just wanted to make sure I was on the correct
track.
Thanks
Jason