다음을 통해 공유


Cursors.GetEnumerator Method

Cursors.GetEnumerator Method

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

Definition

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

Return Value

Microsoft.Ink.Cursors.CursorsEnumerator. Returns an object that implements the IEnumerator Leave Site interface and that can iterate through the Cursor objects within the Cursors collection.

Examples

[C#]

These C# examples show two ways to iterate over the Cursors collection and get the name for each Cursor object in the InkCollector object, theInkCollector. The Cursors collection is returned by the InkCollector.Cursors property.

This C# example gets the IEnumerator Leave Site for the Cursors collection in the InkCollector object, theInkCollector.

[// Version using GetEnumerator()
ArrayList names = new Arraylist();
IEnumerator ienum = theInkCollector.Cursors.GetEnumerator();
while (ienum.MoveNext())
{
    Cursor theCursor = (Cursor) ienum.Current;
    names.Add(theCursor.Name);
}

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

ArrayList names = new ArrayList();
// Version using foreach
foreach (Cursor theCursor in theInkCollector.Cursors)
{
    names.Add(theCursor.Name);
}

[VB.NET]

These Microsoft® Visual Basic® .NET examples show two ways to iterate over the Cursors collection and get the name for each Cursor object in the InkCollector object, theInkCollector. The Cursors collection is returned by the InkCollector.Cursors property.

This Visual Basic .NET example gets the IEnumerator Leave Site for the Cursors collection in the InkCollector object, theInkCollector.

'Version using GetEnumerator()
Dim names As New ArrayList()
Dim theCursor as Cursor
Dim ienum as IEnumerator = theInkCollector.Cursors.GetEnumerator()
While (ienum.MoveNext())
    theCursor = ienum.Current
    names.Add(theCursor.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 names As New ArrayList()
Dim theButton as CursorButton

For Each theCursor In theInkCollector.Cursors
    names.Add(theCursor.Name)
Next

See Also