SortedList Class represents a collection of key/value pairs that are sorted by the keys
Imports System
Imports System.Collections
Imports Microsoft.VisualBasic
Public Class SamplesSortedList
Public Shared Sub Main()
Dim mySL As New SortedList()
mySL.Add("A", "!")
mySL.Add("B", "World")
mySL.Add("C", "Hello")
Console.WriteLine(" Count: {0}", mySL.Count)
Console.WriteLine(" Capacity: {0}", mySL.Capacity)
PrintKeysAndValues(mySL)
End Sub
Public Shared Sub PrintKeysAndValues(myList As SortedList)
Dim i As Integer
For i = 0 To myList.Count - 1
Console.WriteLine("{0}:" & "{1}", myList.GetKey(i), myList.GetByIndex(i))
Next i
End Sub
End Class
Related examples in the same category