Get key list in a SortedList in CSharp
Description
The following code shows how to get key list in a SortedList.
Example
using System;/*from w w w . j av a 2 s .com*/
using System.Collections;
class MainClass
{
public static void Main()
{
SortedList mySortedList = new SortedList();
mySortedList.Add("NY", "New York");
mySortedList.Add("FL", "Florida");
mySortedList.Add("AL", "Alabama");
mySortedList.Add("WY", "Wyoming");
mySortedList.Add("CA", "California");
IList myKeyList = mySortedList.GetKeyList();
foreach(string myKey in myKeyList)
{
Console.WriteLine("myKey = " + myKey);
}
}
}
The code above generates the following result.