System.Text.RegularExpressions.MatchCollection.Count Property

Gets the number of matches.

Syntax

public int Count { get; }

Value

Documentation for this section has not yet been entered.

Remarks

Accessing individual members of the System.Text.RegularExpressions.MatchCollection object by retrieving the value of the collection's MatchCollection.Count property causes the regular expression engine to populate the collection using direct evaluation. ln contrast, calling the MatchCollection.GetEnumerator method (or using 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. Direct evaluation can be a much more expensive method of building the collection than lazy evaluation.

Because the System.Text.RegularExpressions.MatchCollection object is generally populated by using lazy evaluation, trying to determine the number of elements in the collection before it has been fully populated may throw a System.Text.RegularExpressions.RegexMatchTimeoutException exception. This exception can be thrown if a time-out value for matching operations is in effect, and the attempt to find a single match exceeds that time-out interval.

Requirements

Namespace: System.Text.RegularExpressions
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0