Imports System
Imports System.Collections
Imports System.Globalization
Public Class SamplesSortedList
Public Shared Sub Main()
Dim mySL4 As New SortedList(StringComparer.InvariantCultureIgnoreCase, 3)
mySL4.Add("FIRST", "Hello")
mySL4.Add("SECOND", "World")
mySL4.Add("THIRD", "!")
Try
mySL4.Add("first", "Ola!")
Catch e As ArgumentException
Console.WriteLine(e)
End Try
PrintKeysAndValues(mySL4)
End Sub 'Main
Public Shared Sub PrintKeysAndValues(ByVal myList As SortedList)
Dim i As Integer
For i = 0 To myList.Count - 1
Console.WriteLine(" {0,-6}: {1}", _
myList.GetKey(i), myList.GetByIndex(i))
Next i
Console.WriteLine()
End Sub
End Class