System.Text.RegularExpressions.MatchCollection Class

Assembly: System.dll
Namespace: System.Text.RegularExpressions
Summary
Represents the set of successful matches found by iteratively applying a regular expression pattern to the input string.
C# Syntax:
[Serializable]
public class MatchCollection : ICollection, IEnumerable
Remarks
The collection is immutable (read-only) and has no public constructor. Instances are returned through the Regex.Matches method.
See also:
System.Text.RegularExpressions Namespace

System.Text.RegularExpressions.MatchCollection Member List:

Public Properties
Count Read-only

Gets the number of captures.
IsReadOnly Read-only

Gets a value that indicates whether the collection is read only.
IsSynchronized Read-only

Gets a value indicating whether access to the collection is synchronized (thread-safe).
Item Read-only

Gets an individual member of the collection.
SyncRoot Read-only

Gets an object that can be used to synchronize access to the collection.
Public Methods
CopyTo Copies all the elements of the collection to the given array starting at the given index.
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetEnumerator Provides an enumerator in the same order as Item[i].
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.Text.RegularExpressions.MatchCollection Member Details

Property: Count (read-only)
Summary
Gets the number of captures.
C# Syntax:
public int Count {get;}
Implements:
ICollection.Count
Remarks
Note that as soon as the Count property is accessed, the regular expression engine must be run to find all matches. But if MatchCollection.GetEnumerator is used to enumerate the matches, the engine will only execute the matches that are required.

Return to top


Property: IsReadOnly (read-only)
Summary
Gets a value that indicates whether the collection is read only.
C# Syntax:
public bool IsReadOnly {get;}

Return to top


Property: IsSynchronized (read-only)
Summary
Gets a value indicating whether access to the collection is synchronized (thread-safe).
C# Syntax:
public bool IsSynchronized {get;}
Implements:
ICollection.IsSynchronized

Return to top


Property: Item (read-only)
Summary
Gets an individual member of the collection.
C# Syntax:
public virtual Match this[int i] {get;}
Parameters:

i

Index into the Match collection.

Exceptions
Exception Type Condition
ArgumentOutOfRangeException i is less than 0 or greater than MatchCollection.Count.

Return to top


Property: SyncRoot (read-only)
Summary
Gets an object that can be used to synchronize access to the collection.
C# Syntax:
public object SyncRoot {get;}
Implements:
ICollection.SyncRoot

Return to top


Method: CopyTo(
   Array array,
   int arrayIndex
)
Summary
Copies all the elements of the collection to the given array starting at the given index.
C# Syntax:
public void CopyTo(
   Array array,
   int arrayIndex
);
Parameters:

array

The array the collection is to be copied into.

arrayIndex

The position in the array where copying is to begin.

Implements:
ICollection.CopyTo
Remarks
Since the collection is copied into the array starting at the given index, the destination array must be at least as large as the entire collection.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~MatchCollection();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetEnumerator()
Summary
Provides an enumerator in the same order as Item[i].
C# Syntax:
public IEnumerator GetEnumerator();
Return Value:
An IEnumerator object that contains all Match objects within the MatchCollection.
Implements:
IEnumerable.GetEnumerator

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.