GetEnumerator Method
Collapse the table of content
Expand the table of content

MatchCollection.GetEnumerator Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Provides an enumerator in the same order as Item.

Namespace:  System.Text.RegularExpressions
Assembly:  System (in System.dll)

'Declaration
Public Function GetEnumerator As IEnumerator

Return Value

Type: System.Collections.IEnumerator
An IEnumerator object that contains all Match objects within the MatchCollection.

Implements

IEnumerable.GetEnumerator

Iterating the members of the MatchCollection object using the GetEnumerator method (or the foreach statement in C# and the For Each...Next statement in Visual Basic) causes the regular expression engine to populate the collection on an as needed basis using lazy evaluation. This is analogous to repeatedly calling the Regex.Match method, and then adding the resulting match to the MatchCollection object. In contrast, the regular expression engine uses direct evaluation to populate the collection all at once when the Count property is accessed. This can be a much more expensive method of building the collection than lazy evaluation.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft