Searches for a specific value
Imports System
Imports System.Collections
Imports Microsoft.VisualBasic
Public Class SamplesSortedList
Public Shared Sub Main()
Dim mySL As New SortedList()
mySL.Add(1, "one")
mySL.Add(3, "three")
mySL.Add(2, "two")
mySL.Add(4, "four")
mySL.Add(0, "zero")
PrintIndexAndKeysAndValues(mySL)
Dim myValue As String = "three"
Console.WriteLine("The value ""{0}"" is at index {1}.", myValue, _
mySL.IndexOfValue(myValue))
End Sub
Public Shared Sub PrintIndexAndKeysAndValues(myList As SortedList)
Dim i As Integer
For i = 0 To myList.Count - 1
Console.WriteLine("[{0}]:{1}{2}", i, myList.GetKey(i),myList.GetByIndex(i))
Next i
End Sub
End Class
Related examples in the same category