Get the value at the specified index of a SortedList in CSharp

Description

The following code shows how to get the value at the specified index of a SortedList.

Example


using System; //from   w w  w  .ja  va  2 s.  com
using System.Collections; 
 
class MainClass { 
  public static void Main() { 
    SortedList sl = new SortedList(); 
     
    sl.Add("a", "A"); 
    sl.Add("b", "B"); 
    sl.Add("c", "C"); 
    sl.Add("d", "D"); 

    sl["e"] = "E"; 
 
    for(int i=0; i<sl.Count; i++) 
      Console.WriteLine(sl.GetByIndex(i)); 
      
  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Collections »




ArrayList
BitArray
Collection
Comparer
HashSet
Hashtable
LinkedList
List
ListDictionary
OrderedDictionary
Queue
SortedList
SortedSet
Stack
StringCollection
StringDictionary