SortedList Concept in .Net

Provides a collection of key-value pairs where the items are sorted according to the key. The items are accessible by both the keys and the index.
Example:
static void Main()
{
SortedList sl = new SortedList();
sl.Add(18, "Java");
sl.Add(5, "C#");
sl.Add(11, "VB.Net");
sl.Add(1, "C++.Net");

Console.WriteLine("The items in the sorted order are...");
Console.WriteLine("\t Key \t\t Value");
Console.WriteLine("\t === \t\t =====");
for(int i=0; i<sl.Count; i++)
{
Console.WriteLine("\t {0} \t\t {1}", sl.GetKey(i),
sl.GetByIndex(i));
}
}



Output

Key Value

==
1 C++.Net
5 C#
11 VB.Net
18 Java

No comments:

Most Recent Post

Most Recent Ado.net FAQ

Most Recent .Net Framework FAQ

Most Recent Configuration Files FAQ

Daily Quote, Inspiration, Motivation and More

Subscribe Blog via Email

Enter your email address: