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.
Assembly: System (in System.dll)
Return Value
Type: System.Collections.IEnumeratorAn IEnumerator object that contains all Match objects within the MatchCollection.
Implements
IEnumerable.GetEnumeratorIterating 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.