Condividi tramite


Metodo Strokes.StrokesEnumerator.Reset

Aggiornamento: novembre 2007

Reimposta l'indice dell'enumeratore all'inizio dell'insieme Strokes.

Spazio dei nomi:  Microsoft.Ink
Assembly:  Microsoft.Ink (in Microsoft.Ink.dll)

Sintassi

'Dichiarazione
Public Sub Reset
'Utilizzo
Dim instance As Strokes..::.StrokesEnumerator

instance.Reset()
public void Reset()
public:
virtual void Reset() sealed
public final void Reset()
public final function Reset()

Implementa

IEnumerator.Reset()

Note

La classe Strokes.StrokesEnumerator supporta lo scorrimento di un insieme Strokes e implementa l'interfaccia IEnumerator.

Questo metodo eredita dal metodo Reset.

Esempi

In questi esempi vengono presentate due modalità per enumerare l'insieme Strokes allo scopo di recuperare ogni oggetto Stroke contenuto nell'insieme. L'insieme Strokes viene restituito dalla proprietà Ink.Strokes.

In questo esempio si ottiene l'oggetto IEnumerator per l'insieme Strokes e lo si utilizza per attraversare l'insieme.

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);
        }
    }
}

In questo esempio viene utilizzata l'istruzione foreach che chiama il metodo GetEnumerator nel codice interno generato dal compilatore per supportare l'istruzione.

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);
        }
    }
}

Piattaforme

Windows Vista

.NET Framework e .NET Compact Framework non supportano tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.

Informazioni sulla versione

.NET Framework

Supportato in: 3.0

Vedere anche

Riferimenti

Strokes.StrokesEnumerator Classe

Membri Strokes.StrokesEnumerator

Spazio dei nomi Microsoft.Ink

Strokes