C# SortedList GetEnumerator
Description
SortedList GetEnumerator
returns an IDictionaryEnumerator
object that iterates through a SortedList object.
Syntax
SortedList.GetEnumerator
has the following syntax.
public virtual IDictionaryEnumerator GetEnumerator()
Returns
SortedList.GetEnumerator
method returns An IDictionaryEnumerator object for the SortedList object.
Example
using System;/* w w w.j a v a 2s . com*/
using System.Collections;
public class HashtableExample
{
public static void Main()
{
SortedList myHT = new SortedList();
myHT.Add("1", "4");
myHT.Add("2", "5");
myHT.Add("3", "6");
IDictionaryEnumerator denum = myHT.GetEnumerator();
DictionaryEntry dentry;
while (denum.MoveNext())
{
dentry = (DictionaryEntry) denum.Current;
Console.WriteLine(" {0,-17}{1}", dentry.Key, dentry.Value);
}
}
}
The code above generates the following result.