Remove all elements from a SortedList in CSharp

Description

The following code shows how to remove all elements from a SortedList.

Example


using System;//from  www  .j a va2s.  c  o m
using System.Collections;
public class SamplesSortedList  {

   public static void Main()  {
      SortedList mySL = new SortedList();
      mySL.Add( "one", "1" );
      mySL.Add( "two", "2" );
      mySL.Add( "three", "3" );

      Console.WriteLine( "   Count    : {0}", mySL.Count );
      Console.WriteLine( "   Capacity : {0}", mySL.Capacity );

      mySL.Clear();

      Console.WriteLine( "   Count    : {0}", mySL.Count );
      Console.WriteLine( "   Capacity : {0}", mySL.Capacity );
   }
}

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