Share via


Strokes.GetEnumerator Method

Returns an object that implements the IEnumerator interface and that can iterate through the Stroke objects within the Strokes collection.

Namespace: Microsoft.Ink
Assembly: Microsoft.Ink (in microsoft.ink.dll)

Syntax

'Declaration
Public Function GetEnumerator As StrokesEnumerator
'Usage
Dim instance As Strokes
Dim returnValue As StrokesEnumerator

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

Return Value

Returns an object that implements the IEnumerator interface and that can iterate through the Stroke objects within the Strokes collection.

Example

These C# examples show two ways to iterate through the Strokes collection retrieving the Id property for each Stroke object in the Ink object, theInk. The Strokes collection is returned by the Ink.Strokes property.

This C# example retrieves the IEnumerator for the Strokes collection.

ArrayList theArrayList = new ArrayList();
// Version using GetEnumerator()
IEnumerator theInkStrokesEnumerator = theInk.Strokes.GetEnumerator();
while (theInkStrokesEnumerator.MoveNext())
{
    Stroke theStroke = (Stroke) theInkStrokesEnumerator.Current;
    theArrayList.Add(theStroke.Id);
}

This C# example uses the foreach statement, which calls the GetEnumerator method in internal code that the compiler generates to support the statement.

ArrayList theArrayList = new ArrayList();
// Version using foreach
foreach (Stroke theStroke in theInk.Strokes)
{
    theArrayList.Add(theStroke.Id);
}

These Microsoft Visual Basic.NET examples show two ways to iterate through the Strokes collection retrieving the Id property for each Stroke object in the Ink object, theInk. The Strokes collection is returned by the Ink.Strokes property.

This Visual Basic .NET example gets the IEnumerator for the Strokes collection.

'Version using GetEnumerator()
Dim theArrayList As New ArrayList
Dim theStroke As Stroke
Dim theInkStrokesEnumerator As IEnumerator = theInk.Strokes.GetEnumerator()
While (theInkStrokesEnumerator.MoveNext())
    theStroke = theInkStrokesEnumerator.Current
    theArrayList.Add(theStroke.Name)
End While

This Visual Basic .NET example uses the For Each statement, which calls the GetEnumerator method in internal code that the compiler generates to support the statement.

'Version using For Each
Dim theArrayList As New ArrayList
Dim theStroke as Stroke

For Each theStroke In theInk.Strokes
    theArrayList.Add(theStroke.Id)
Next

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

Strokes Class
Strokes Members
Microsoft.Ink Namespace
Stroke
Ink.Strokes