Compartir a través de


DivisionUnits.GetEnumerator Method

DivisionUnits.GetEnumerator Method

Returns an object that implements the System.Collections.IEnumerator Leave Site interface and that can iterate through the DivisionUnit objects within the DivisionUnits collection.

Definition

Visual Basic .NET Public Function GetEnumerator() As InkDivisionUnitsEnumerator
C# public InkDivisionUnitsEnumerator GetEnumerator();
Managed C++ public: InkDivisionUnitsEnumerator* GetEnumerator();

Return Value

Microsoft.Ink.DivisionUnits.InkDivisionUnitsEnumerator. Returns an object that implements the IEnumerator Leave Site interface and that can iterate through the DivisionUnit objects within the DivisionUnits collection.

Examples

[C#]

These C# examples show two ways to iterate over the DivisionUnits collection and get the recognized text for each DivisionUnit object in the DivisionResult object, theDivisionResult. The DivisionUnits collection is returned by the DivisionResult.ResultByType method.

This C# example gets the IEnumerator Leave Site for the DivisionUnits collection.

ArrayList theRecognizedText = new ArrayList();
DivisionUnits theDivisionUnits = theDivisionResult.ResultByType(InkDivisionType.Paragraph);
// Version using GetEnumerator()
System.Collections.IEnumerator theEnumerator = theDivisionUnits.GetEnumerator();
while ( theEnumerator.MoveNext() )
{
    DivisionUnit theDivisionUnit = (DivisionUnit) theEnumerator.Current;
    theRecognizedText.Add(theDivisionUnit.RecognitionString);
}

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

ArrayList theRecognizedText = new ArrayList();
DivisionUnit theDivisionUnits = theDivisionResult.ResultByType(InkDivisionType.Paragraph);
// Version using foreach
foreach (DivisionUnit theDivisionUnit in theDivisionUnits)
{
    theRecognizedText.Add(theDivisionUnit.RecognitionString);
}

[VB.NET]

These Microsoft® Visual Basic® .NET examples show two ways to iterate over the DivisionUnits collection and get the recognized text for each DivisionUnit object in the DivisionResult object, theDivisionResult. The DivisionUnits collection is returned by the DivisionResult.ResultByType method.

This Visual Basic .NET example gets the IEnumerator Leave Site for the DivisionUnits collection.

Dim theDivider As Divider
'...
Dim theDivisionResult As DivisionResult = theDivider.Divide()
Dim theRecognizedText As New ArrayList()
Dim theDivisionUnits As DivisionUnits = theDivisionResult.ResultByType(InkDivisionType.Paragraph)
'Version using GetEnumerator
Dim theEnumerator As IEnumerator = theDivisionUnits.GetEnumerator()
While (theEnumerator.MoveNext())
    Dim theDivisionUnit As DivisionUnit = theEnumerator.Current
    theRecognizedText.Add(theDivisionUnit.RecognitionString)
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.

Dim theDivisionResult As DivisionResult = theDivider.Divide()
Dim theRecognizedText As New ArrayList()
Dim theDivisionUnits As DivisionUnits = theDivisionResult.ResultByType(InkDivisionType.Paragraph)
'Version using For Each
For Each DivisionUnit In theDivisionUnits
    theRecognizedText.Add(theDivisionUnit.RecognitionString)
Next

See Also