다음을 통해 공유


Strokes.GetEnumerator 메서드

업데이트: 2007년 11월

IEnumerator 인터페이스를 구현하고 Strokes 컬렉션 내에서 Stroke 개체를 반복할 수 있는 개체를 반환합니다.

네임스페이스:  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
IEnumerator 인터페이스를 구현하고 Strokes 컬렉션 내에서 Stroke 개체를 반복할 수 있는 개체를 반환합니다.

예제

이 예제에서는 Strokes 컬렉션을 열거하여 컬렉션에 들어 있는 각 Stroke 개체를 검색하는 두 가지 방법을 보여 줍니다. Ink.Strokes 속성에서 Strokes 컬렉션을 반환합니다.

이 예제에서는 Strokes 컬렉션의 IEnumerator를 가져와서 컬렉션을 순회하는 데 사용합니다.

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

이 예제에서는 foreach 문을 사용합니다. 이 명령문을 지원하기 위해 컴파일러에서 생성하는 내부 코드는 GetEnumerator 메서드를 호출합니다.

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