Create a SortedList using the specified CaseInsensitiveComparer
Imports System
Imports System.Collections
Imports System.Globalization
Public Class SamplesSortedList
Public Shared Sub Main()
Dim myCul As New CultureInfo("tr-TR")
Dim mySL3 As New SortedList(New CaseInsensitiveComparer(myCul), 3)
mySL3.Add("FIRST", "Hello")
mySL3.Add("SECOND", "World")
mySL3.Add("THIRD", "!")
Try
mySL3.Add("first", "A!")
Catch e As ArgumentException
Console.WriteLine(e)
End Try
PrintKeysAndValues(mySL3)
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
Related examples in the same category