Strokes.GetEnumerator Method
Returns an object that implements the IEnumerator interface and that can iterate through the Stroke objects within the Strokes collection.
Namespace: Microsoft.Ink
Assembly: Microsoft.Ink (in Microsoft.Ink.dll)
Syntax
'Declaration
Public Function GetEnumerator As Strokes.StrokesEnumerator
'Usage
Dim instance As Strokes
Dim returnValue As Strokes.StrokesEnumerator
returnValue = instance.GetEnumerator()
public Strokes.StrokesEnumerator GetEnumerator()
public:
Strokes.StrokesEnumerator^ GetEnumerator()
public function GetEnumerator() : Strokes.StrokesEnumerator
Return Value
Type: Microsoft.Ink.Strokes.StrokesEnumerator
Returns an object that implements the IEnumerator interface and that can iterate through the Stroke objects within the Strokes collection.
Examples
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);
}
}
}
Platforms
Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information
.NET Framework
Supported in: 3.0