C# SortedSet GetEnumerator
Description
SortedSet
returns an enumerator
that iterates through the SortedSet
Syntax
SortedSet.GetEnumerator
has the following syntax.
public SortedSet<T>.Enumerator GetEnumerator()
Returns
SortedSet.GetEnumerator
method returns An enumerator that iterates through
the SortedSet in sorted order.
Example
using System;/*from ww w .j av a2 s. c om*/
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");
IEnumerator e = set1.GetEnumerator();
while (e.MoveNext())
{
Object obj = e.Current;
Console.WriteLine(obj);
}
}
}
The code above generates the following result.