Get the number of elements contained in a SortedList object in CSharp

Description

The following code shows how to get the number of elements contained in a SortedList object.

Example


/*from ww w  . j  av  a 2 s . c  o m*/
using System; 
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"); 
 
    Console.WriteLine(sl.Count); 
  }
}

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