See Also: GroupCollection Members
The System.Text.RegularExpressions.GroupCollection class consists of one or more System.Text.RegularExpressions.Group objects that provide information about captured groups in a regular expression match. The collection is immutable (read-only) and has no public constructor. A System.Text.RegularExpressions.GroupCollection object is returned by the Match.Groups property.
The collection contains one or more System.Text.RegularExpressions.Group objects. If the match is successful, the first element in the collection contains the System.Text.RegularExpressions.Group object that corresponds to the entire match. Each subsequent element represents a captured group, if the regular expression includes capturing groups. Matches from numbered (unnamed) capturing groups appear in numeric order before matches from named capturing groups. If the match is unsuccessful, the collection contains a single System.Text.RegularExpressions.Group object whose Group.Success property is false and whose Capture.Value property equals string.Empty. For more information, see the "Grouping Constructs and Regular Expression Objects" section in the Grouping Constructs in Regular Expressions article.
To iterate through the members of the collection, you should use the collection iteration construct provided by your language (such as foreach in C# and For Each…Next in Visual Basic) instead of retrieving the enumerator that is returned by the GroupCollection.GetEnumerator method.