MatchCollection.GetEnumerator Metodo
Definizione
Fornisce un enumeratore che scorre la raccolta.Provides an enumerator that iterates through the collection.
public:
virtual System::Collections::IEnumerator ^ GetEnumerator();
public System.Collections.IEnumerator GetEnumerator ();
abstract member GetEnumerator : unit -> System.Collections.IEnumerator
override this.GetEnumerator : unit -> System.Collections.IEnumerator
Public Function GetEnumerator () As IEnumerator
Restituisce
Oggetto contenente tutti gli oggetti Match all'interno di MatchCollection.An object that contains all Match objects within the MatchCollection.
Implementazioni
Eccezioni
Si è verificato un timeout.A time-out occurred.
Commenti
Anziché chiamare il GetEnumerator metodo per recuperare un enumeratore che consente di scorrere For Each
gli Match oggetti nella raccolta, è necessario utilizzare il costrutto di foreach
iterazione del gruppo, ad C# esempio in e...Next
Instead of calling the GetEnumerator method to retrieve an enumerator that lets you iterate through the Match objects in the collection, you should use the group iteration construct (such as foreach
in C# and For Each
…Next
in Visual Basic) fornita dal linguaggio di programmazione.in Visual Basic) provided by your programming language.
Iterazione dei membri dell' MatchCollection oggetto utilizzando il GetEnumerator metodo (o For Each
l' foreach
istruzione in C# e... Next
in Visual Basic) fa in modo che il motore delle espressioni regolari popola la raccolta in base alle esigenze usando la valutazione lazy.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. Questa operazione è analoga a quella Regex.Match di chiamare ripetutamente il metodo e quindi MatchCollection di aggiungere la corrispondenza risultante all'oggetto.This is analogous to repeatedly calling the Regex.Match method, and then adding the resulting match to the MatchCollection object. Al contrario, il motore delle espressioni regolari utilizza la valutazione diretta per popolare la raccolta in una sola Count volta quando si accede alla proprietà.In contrast, the regular expression engine uses direct evaluation to populate the collection all at once when the Count property is accessed. Questo può essere un metodo molto più costoso per compilare la raccolta rispetto alla valutazione lazy.This can be a much more expensive method of building the collection than lazy evaluation.
Poiché l' MatchCollection oggetto viene generalmente popolato utilizzando la valutazione lazy, il tentativo di passare al membro successivo della raccolta può generare un' RegexMatchTimeoutException eccezione.Because the MatchCollection object is generally populated by using lazy evaluation, trying to navigate to the next member of the collection may throw a RegexMatchTimeoutException exception. Questa eccezione può essere generata se è attivo un valore di timeout per le operazioni di corrispondenza e il tentativo di trovare la corrispondenza successiva supera tale intervallo di timeout.This exception can be thrown if a time-out value for matching operations is in effect, and the attempt to find the next match exceeds that time-out interval.