Get an IEnumerable that iterates over the SortedSet in reverse order in CSharp

Description

The following code shows how to get an IEnumerable that iterates over the SortedSet in reverse order.

Example


using System;//  w  w  w. j  ava 2  s .c o m
using System.Collections;
using System.Collections.Generic;
using System.IO;


class Program
{
    static void Main(string[] args)
    {
        SortedSet<string> set1 = new SortedSet<string>();
        set1.Add("a");
        set1.Add("b");
        set1.Add("d");
        set1.Add("d");


        IEnumerable<String> ie = set1.Reverse();

        foreach (string s in ie)
        {
            Console.WriteLine(s);
        }


    }
}

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