Strokes.StrokesEnumerator.MoveNext 方法

将枚举数索引移到集合中的下一对象。

命名空间:  Microsoft.Ink
程序集:  Microsoft.Ink(在 Microsoft.Ink.dll 中)

语法

声明
Public Function MoveNext As Boolean
用法
Dim instance As Strokes..::.StrokesEnumerator
Dim returnValue As Boolean

returnValue = instance.MoveNext()
public bool MoveNext()
public:
virtual bool MoveNext() sealed
public final boolean MoveNext()
public final function MoveNext() : boolean

返回值

类型:System.Boolean
如果索引位置引用对象,则设置为 true;如果索引位置引用集合末尾,则设置为 false。

实现

IEnumerator.MoveNext()

备注

Strokes.StrokesEnumerator 支持循环访问 Strokes 集合,并实现 IEnumerator 接口。

此方法继承自 MoveNext

示例

这些示例演示两种枚举 Strokes 集合以检索集合中包含的每个 Stroke 对象的方法。Strokes 集合由 Ink.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.StrokesEnumerator 类

Strokes.StrokesEnumerator 成员

Microsoft.Ink 命名空间

Strokes