Create a SortedList using CaseInsensitiveComparer based on the Turkish culture (tr-TR)
using System;
using System.Collections;
using System.Globalization;
public class SamplesSortedList
{
public static void Main()
{
CultureInfo myCul = new CultureInfo("tr-TR");
SortedList mySL3 = new SortedList(new CaseInsensitiveComparer(myCul));
mySL3.Add("A", "a");
mySL3.Add("B", "b");
mySL3.Add("C", "c");
try
{
mySL3.Add("first", "asdf");
}
catch (ArgumentException e)
{
Console.WriteLine(e);
}
PrintKeysAndValues(mySL3);
}
public static void PrintKeysAndValues(SortedList myList)
{
Console.WriteLine(" -KEY- -VALUE-");
for (int i = 0; i < myList.Count; i++)
{
Console.WriteLine(" {0,-6}: {1}",
myList.GetKey(i), myList.GetByIndex(i));
}
Console.WriteLine();
}
}
Related examples in the same category