Create a SortedList using the CaseInsensitiveComparer based on the Turkish culture (tr-TR) : SortedList « Data Structure « VB.Net






Create a SortedList using the CaseInsensitiveComparer based on the Turkish culture (tr-TR)

  
 
Imports System
Imports System.Collections
Imports System.Globalization

Public Class SamplesSortedList
    Public Shared Sub Main()
        Dim myHT As New Hashtable()
        myHT.Add("FIRST", "Hello")
        myHT.Add("SECOND", "World")
        myHT.Add("THIRD", "!")

        Dim myCul As New CultureInfo("tr-TR")
        Dim mySL3 As New SortedList(myHT, New CaseInsensitiveComparer(myCul))

        Try
            mySL3.Add("first", "AA")
        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
    End Sub

End Class

   
    
  








Related examples in the same category

1.Create a SortedList using the default comparer
2.Create a SortedList using the specified case-insensitive comparer
3.Create a SortedList using the StringComparer.InvariantCultureIgnoreCase value
4.Simple Example for Sorted ListSimple Example for Sorted List
5.Create Case Insensitive Sorted ListCreate Case Insensitive Sorted List
6.Output Items in a SortedListOutput Items in a SortedList
7.SortedList Class represents a collection of key/value pairs that are sorted by the keys
8.Create a SortedList using the default comparer
9.Create a SortedList using the specified case-insensitive comparer
10.Create a SortedList using the specified CaseInsensitiveComparer
11.Create a SortedList using the StringComparer.InvariantCultureIgnoreCase value
12.Create SortedList that contains elements from dictionary
13.SortedList(TKey, TValue) represents a collection of key/value pairs that are sorted by key based
14.The Add method throws an exception if the new key is already in the list.
15.Item property is the default property, so you can omit its name when accessing elements
16.The default Item property can be used to change the value associated with a key
17.If a key does not exist, setting the default Item property for that key adds a new key/value pair
18.The default Item property throws an exception if the requested key is not in the list
19.TryGetValue can be a more efficient way to retrieve values
20.ContainsKey can be used to test keys before inserting them
21.When using foreach to enumerate list elements, the elements are retrieved as KeyValuePair objects
22.To get the values alone, use the Values property
23.The Values property is an efficient way to retrieve values by index
24.To get the keys alone, use the Keys property
25.The Keys property is an efficient way to retrieve keys by index
26.Use the Remove method to remove a key/value pair
27.SortedList.Add Method adds key and value to a SortedList object.
28.SortedList.Clear Method removes all elements from a SortedList object.
29.SortedList.Contains Method determines whether a SortedList object contains a specific key.
30.SortedList.CopyTo Method copies SortedList to a one-dimensional Array
31.SortedList.GetByIndex Method gets the value at the specified index of a SortedList object.
32.SortedList.IndexOfKey Method returns the zero-based index of the specified key in a SortedList object.
33.Searches for a specific key
34.Searches for a specific value
35.SortedList.IsSynchronized Property tells whether access to a SortedList object is synchronized (thread safe).
36.SortedList.Remove removes element with the specified key from a SortedList object.
37.SortedList.SetByIndex Method replaces the value at a specific index in a SortedList object.