SortedList.GetKeyList Method is used to get the list of keys in a SortedList object.
public virtual System.Collections.IList GetKeyList ();
Return Value: It returns an IList object containing the keys in the SortedList object.
Below programs illustrate the use of above-discussed method:
Key List 1 2 3 4 5
Key List Fifth First Fourth Second Third
- The returned IList object is a read-only view of the keys of the SortedList object. Modifications made to the underlying SortedList are immediately reflected in the IList.
- The elements of the returned IList are sorted in the same order as the keys of the SortedList.
- This method is similar to the Keys property but returns an IList object instead of an ICollection object.
- This method is an O(1) operation.