Remove all elements from SortedSet in CSharp

Description

The following code shows how to remove all elements from SortedSet.

Example


//from  w  w w .j  a v a  2s  .c  o m
using System;

using System.Collections.Generic;


public class MainClass
{
    public static void Main(String[] argv)
    {
        SortedSet<int> evenNumbers = new SortedSet<int>();
        for (int i = 0; i < 5; i++)
        {
            evenNumbers.Add(i * 2);
        }

        foreach (int i in evenNumbers)
        {
            Console.WriteLine(i);
        }

        evenNumbers.Clear();

        Console.WriteLine(evenNumbers.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