Create a SortedList using the default comparer
Imports System Imports System.Collections Imports System.Globalization Public Class SamplesSortedList Public Shared Sub Main() Dim mySL1 As New SortedList( 3 ) mySL1.Add("FIRST", "Hello") mySL1.Add("SECOND", "World") mySL1.Add("THIRD", "!") Try mySL1.Add("first", "A") Catch e As ArgumentException Console.WriteLine(e) End Try PrintKeysAndValues(mySL1) End Sub 'Main Public Shared Sub PrintKeysAndValues(ByVal myList As SortedList) Console.WriteLine(" -KEY- -VALUE-") 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