VB.Net Tutorial/Collections/CollectionsUtil

Материал из VB Эксперт
Перейти к: навигация, поиск

CollectionsUtil.CreateCaseInsensitiveSortedList

Imports System.Collections.Specialized
Imports System.Collections
public class Test
  
   public Shared Sub Main
        Dim sorted_list As SortedList
        " Use a normal, case-sensitive SortedList.
        sorted_list = New SortedList
        sorted_list.Add("Sport", "Volleyball")
        sorted_list.Add("sport", "Golf")        " Okay because Sport <> sport.
        " Use a case-insensitive SortedList.
        sorted_list = CollectionsUtil.CreateCaseInsensitiveSortedList()
        sorted_list.Add("Sport", "Volleyball")
        sorted_list.Add("sport", "Golf")        " Error because Sport = sport.
   End Sub
   
End class
Unhandled Exception: System.ArgumentException: Item has already been added. Key in dictionary: "Spor
t"  Key being added: "sport"
   at System.Collections.SortedList.Add(Object key, Object value)
   at Test.Main()