using System;
using System.Collections;
using System.Globalization;
public class SamplesSortedList
{
public static void Main()
{
Hashtable myHT = new Hashtable();
myHT.Add("FIRST", "Hello");
myHT.Add("SECOND", "World");
myHT.Add("THIRD", "!");
CultureInfo myCul = new CultureInfo("tr-TR");
SortedList mySL3 = new SortedList(myHT, new CaseInsensitiveComparer(myCul));
try
{
mySL3.Add("first", "Ola!");
}
catch (ArgumentException e)
{
Console.WriteLine(e);
}
PrintKeysAndValues(mySL3);
}
public static void PrintKeysAndValues(SortedList myList)
{
for (int i = 0; i < myList.Count; i++)
{
Console.WriteLine(myList.GetKey(i));
Console.WriteLine(myList.GetByIndex(i));
}
}
}
|