How to get a KEY from a sorted list (not a VALUE) ??

  • Thread starter Thread starter pamelafluente
  • Start date Start date
P

pamelafluente

Hi,

I have a SortedList "MySortedList". I want to get the KEY, not the
VALUE. How can i do that ?? Possibly I want a O(1) operation:


If MySortedList.ContainsKey(SomeObject) Then

SomeObject_ContainedKey = MySortedList.??what????(SomeObject)

End If


PS.
Please note that SomeObject and SomeObject_ContainedKey (the one I want
to get) are *not* the same because clearly I am assuming ContainsKey
return TRUE based on some comparer.


-P
 
Dim index As Integer = MySortedList.IndexOfKey(SomeObject)
If index >= 0 Then
SomeObject_ContainedKey = MySortedList.GetKey(index)
End If

/claes
 
Back
Top