Поделиться через


Strokes.GetEnumerator - метод

Обновлен: Ноябрь 2007

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

Пространство имен:  Microsoft.Ink
Сборка:  Microsoft.Ink (в Microsoft.Ink.dll)

Синтаксис

'Декларация
Public Function GetEnumerator As Strokes..::.StrokesEnumerator
'Применение
Dim instance As Strokes
Dim returnValue As Strokes..::.StrokesEnumerator

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

Возвращаемое значение

Тип: Microsoft.Ink.Strokes.StrokesEnumerator
Returns an object that implements the IEnumerator interface and that can iterate through the Stroke objects within the Strokes collection.

Примеры

These examples show two ways to enumerate the Strokes collection in order to retrieve each Stroke object contained in the collection. The Strokes collection is returned by the Ink.Strokes property.

This example obtains the IEnumerator for the Strokes collection, and uses it to traverse the collection.

Private Sub EnumerateStrokesWithEnumerator(ByVal mInk As Ink)
    ' access the Strokes property via using statement
    ' to insure that the object mStrokes is disposed when finished
    ' Otherwise, you will have a memory leak
    Using mStrokes As Strokes = mInk.Strokes
        Dim mStrokesEnumerator As IEnumerator = mStrokes.GetEnumerator()
        mStrokesEnumerator.Reset()
        While (mStrokesEnumerator.MoveNext())
            Dim S As Stroke = DirectCast(mStrokesEnumerator.Current, Stroke)
            Me.listBoxStrokeId.Items.Add(S.Id)
        End While
    End Using
End Sub
private void EnumerateStrokesWithEnumerator(Ink mInk)
{
    // access the Strokes property via using statement
    // to insure that the object mStrokes is disposed when finished
    // Otherwise, you will have a memory leak
    using (Strokes mStrokes = mInk.Strokes)
    {
        IEnumerator mStrokesEnumerator = mStrokes.GetEnumerator();
        mStrokesEnumerator.Reset();
        while (mStrokesEnumerator.MoveNext())
        {
            Stroke S = (Stroke)mStrokesEnumerator.Current;
            this.listBoxStrokeId.Items.Add(S.Id);
        }
    }
}

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

Private Sub EnumerateStrokesWithForEach(ByVal mInk As Ink)
    ' access the Strokes property via using statement
    ' to insure that the object mStrokes is disposed when finished
    ' Otherwise, you will have a memory leak
    Using mStrokes As Strokes = mInk.Strokes
        For Each S As Stroke In mStrokes
            Me.listBoxStrokeId.Items.Add(S.Id)
        Next
    End Using
End Sub
private void EnumerateStrokesWithForEach(Ink mInk)
{    
    // access the Strokes property via using statement
    // to insure that the object mStrokes is disposed when finished
    // Otherwise, you will have a memory leak
    using (Strokes mStrokes = mInk.Strokes)
    {
        foreach (Stroke S in mStrokes)
        {
            this.listBoxStrokeId.Items.Add(S.Id);
        }
    }
}

Платформы

Windows Vista

Среды .NET Framework и .NET Compact Framework поддерживают не все версии каждой платформы. Поддерживаемые версии перечислены в разделе Требования к системе для .NET Framework.

Сведения о версии

.NET Framework

Поддерживается в версии: 3.0

См. также

Ссылки

Strokes Класс

Strokes - члены

Microsoft.Ink - пространство имен

Stroke

Ink.Strokes