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
 

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