CSharpTest.Net
GetEnumerator Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeDictionary<TKey,TValue> Class : GetEnumerator Method

Glossary Item Box

Returns an enumerator that iterates through the collection.

Syntax

Visual Basic (Declaration) 
Public Function GetEnumerator() As IEnumerator(Of KeyValuePair(Of TKey,TValue))
C# 
public IEnumerator<KeyValuePair<TKey,TValue>> GetEnumerator()

Example

Library/Library.Test/TestBTreeDictionary.cs

C#Copy Code
BTreeDictionary<int, string> data = new BTreeDictionary<int, string>(Comparer, GetSample());
BTreeDictionary<int, string> copy = (BTreeDictionary<int, string>) ((ICloneable) data).Clone();
using(IEnumerator<KeyValuePair<int, string>> e1 = data.GetEnumerator())
using(IEnumerator<KeyValuePair<int, string>> e2 = copy.GetEnumerator())
{
    while(e1.MoveNext() && e2.MoveNext())
    {
        Assert.AreEqual(e1.Current.Key, e2.Current.Key);
        Assert.AreEqual(e1.Current.Value, e2.Current.Value);
    }
    Assert.IsFalse(e1.MoveNext() || e2.MoveNext());
}
VB.NETCopy Code
Dim data As New BTreeDictionary(Of Integer, String)(Comparer, GetSample())
Dim copy As BTreeDictionary(Of Integer, String) = DirectCast((DirectCast(data, ICloneable)).Clone(), BTreeDictionary(Of Integer, String))
Using e1 As IEnumerator(Of KeyValuePair(Of Integer, String)) = data.GetEnumerator()
    Using e2 As IEnumerator(Of KeyValuePair(Of Integer, String)) = copy.GetEnumerator()
        While e1.MoveNext() AndAlso e2.MoveNext()
            Assert.AreEqual(e1.Current.Key, e2.Current.Key)
            Assert.AreEqual(e1.Current.Value, e2.Current.Value)
        End While
        Assert.IsFalse(e1.MoveNext() OrElse e2.MoveNext())
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys