MatchCollection.Item[Int32] 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得集合的個別成員。
public:
virtual property System::Text::RegularExpressions::Match ^ default[int] { System::Text::RegularExpressions::Match ^ get(int i); };
public virtual System.Text.RegularExpressions.Match this[int i] { get; }
member this.Item(int) : System.Text.RegularExpressions.Match
Default Public Overridable ReadOnly Property Item(i As Integer) As Match
參數
屬性值
在集合中位置 i 捕捉的子字串。
實作
例外狀況
i 小於 0 或大於或等於 Count。
備註
在 C# 中,這個Item[Int32]屬性是一個索引器;它在程式碼中並未明確引用,而是允許以陣列方式存取。MatchCollection
通常,在確定該物業Count的總項目數量後,才會透過索引存取個別項目MatchCollection。 然而,存取該 Count 屬性會使正則表達式引擎使用直接求值一次性建構集合。 這通常比用 GetEnumerator() 方法或 foreach 陳述式迭代集合更昂貴。
由於物件 MatchCollection 通常是透過懶惰評估來填充,嘗試導向特定匹配可能會拋出 RegexMatchTimeoutException 例外。 若匹配操作的逾時值生效,且尋找特定匹配的嘗試超過該逾時區間,則可拋出此例外。