Share via


ContextNodeCollection.GetEnumerator Method

Returns an object that both implements the IEnumerator interface, and can iterate through the ContextNode objects within the ContextNodeCollection.

Namespace: System.Windows.Ink
Assembly: IAWinFX (in iawinfx.dll)

Syntax

'Declaration
Public Function GetEnumerator As ContextNodeCollectionEnumerator
'Usage
Dim instance As ContextNodeCollection
Dim returnValue As ContextNodeCollectionEnumerator

returnValue = instance.GetEnumerator
public ContextNodeCollectionEnumerator GetEnumerator ()
public:
ContextNodeCollectionEnumerator^ GetEnumerator ()
public ContextNodeCollectionEnumerator GetEnumerator ()
public function GetEnumerator () : ContextNodeCollectionEnumerator
Not applicable.

Return Value

An object that both implements the IEnumerator interface, and can iterate through the ContextNode objects within the ContextNodeCollection.

Example

The examples in this section show two ways to iterate through a ContextNodeCollection and get the identifiers for all of the lines in an InkAnalyzer, theInkAnalyzer.

The following example gets the IEnumerator for the ContextNodeCollection, lines.

Dim ids As New ArrayList()
' Version using GetEnumerator()
Dim lines As ContextNodeCollection = theInkAnalyzer.FindNodesOfType(ContextNodeType.Line)
Dim ienum As IEnumerator = lines.GetEnumerator()
While ienum.MoveNext()
    Dim id As Guid = CType(ienum.Current, ContextNode).Id
    ids.Add(id)
End While
ArrayList ids = new ArrayList();
// Version using GetEnumerator()
ContextNodeCollection lines =
    theInkAnalyzer.FindNodesOfType(ContextNodeType.Line);
IEnumerator ienum = lines.GetEnumerator();
while (ienum.MoveNext())
{
    Guid id = ((ContextNode)ienum.Current).Id;
    ids.Add(id);
}

The following example uses the foreach statement, which calls the GetEnumerator method in internal code generated by the compiler to support the statement.

' Version using foreach
Dim line As ContextNode
For Each line In  lines
    Dim id As Guid = line.Id
    ids.Add(id)
Next line
// Version using foreach
foreach (ContextNode line in lines)
{
    Guid id = line.Id;
    ids.Add(id);
}

Platforms

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

ContextNodeCollection Class
ContextNodeCollection Members
System.Windows.Ink Namespace