Share via


Recognizers.GetEnumerator Method

Recognizers.GetEnumerator Method

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

Definition

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

Return Value

Microsoft.Ink.Recognizers.RecognizersEnumerator. Returns an object that implements the IEnumerator Leave Site interface and that can iterate through the Recognizer objects within the Recognizers collection.

Examples

[C#]

These C# examples show two ways to iterate over the Recognizers collection and get the name for each Recognizer object in the Recognizers collection, theRecognizers.

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

Recognizers theRecognizers = new Recognizers();
ArrayList theArrayList = new ArrayList(theRecognizers.Count);
            
//Version using IEnumerator
IEnumerator theEnumerator = theRecognizers.GetEnumerator();
while(theEnumerator.MoveNext())
    {

        Recognizer theRecognizer = (Recognizer) theEnumerator.Current;
        theArrayList.Add(theRecognizer.Name);
    }

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

Recognizers theRecognizers = new Recognizers();
ArrayList theArrayList = new ArrayList();
//Version using foreach
foreach (Recognizer theRecognizer in theRecognizers)
    {
        theArrayList.Add(theRecognizer.Name);
    }

[VB.NET]

These Microsoft® Visual Basic® .NET examples show two ways to iterate over the Recognizers collection and get the name for each Recognizer object in the Recognizer object, theRecognizer.

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

Imports Microsoft.Ink
...
  Sub IEnumerator_Method()
    'Version using GetEnumerator()
    Dim theArrayList As New ArrayList()
    Dim theRecognizers As New Recognizers()
    Dim theRecognizer As Recognizer

    Dim theEnumerator As IEnumerator = theRecognizers.GetEnumerator()
    While (theEnumerator.MoveNext())
        theRecognizer = theEnumerator.Current
        theArrayList.Add(theRecognizer.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.

Imports Microsoft.Ink
...
'Version using For Each
Dim theArrayList As New ArrayList()
Dim theRecognizers As New Recognizers()

For Each theRecognizer In theRecognizers
    theArrayList.Add(theRecognizer.Name)
Next

See Also