Create SortedList and sorted according to the specified IComparer in CSharp
Description
The following code shows how to create SortedList and sorted according to the specified IComparer.
Example
using System;//from ww w . ja v a 2s. c o m
using System.Collections;
using System.Globalization;
public class SamplesSortedList
{
public static void Main()
{
SortedList mySL2 = new SortedList(new CaseInsensitiveComparer(), 3);
mySL2.Add("FIRST", "Hello");
mySL2.Add("SECOND", "World");
mySL2.Add("THIRD", "!");
mySL2.Add("first", "Ola!");
for (int i = 0; i < mySL2.Count; i++)
{
Console.WriteLine(mySL2.GetKey(i)+" "+ mySL2.GetByIndex(i));
}
}
}