共用方式為


CodeCatchClauseCollection.IndexOf(CodeCatchClause) 方法

定義

取得集合中指定之 CodeCatchClause 物件的索引 (如果它存在於集合中的話)。

public:
 int IndexOf(System::CodeDom::CodeCatchClause ^ value);
public int IndexOf (System.CodeDom.CodeCatchClause value);
member this.IndexOf : System.CodeDom.CodeCatchClause -> int
Public Function IndexOf (value As CodeCatchClause) As Integer

參數

value
CodeCatchClause

要放置在集合中的 CodeCatchClause 物件。

傳回

如果找到的話,就是集合中指定的物件之索引,否則為 -1。

範例

下列範例會搜尋特定 CodeCatchClause 物件是否存在,並使用 IndexOf 方法來取得找到它的索引值。

// Tests for the presence of a CodeCatchClause in the 
// collection, and retrieves its index if it is found.
CodeCatchClause^ testClause = gcnew CodeCatchClause( "e" );
int itemIndex = -1;
if ( collection->Contains( testClause ) )
   itemIndex = collection->IndexOf( testClause );
// Tests for the presence of a CodeCatchClause in the
// collection, and retrieves its index if it is found.
CodeCatchClause testClause = new CodeCatchClause("e");
int itemIndex = -1;
if( collection.Contains( testClause ) )
    itemIndex = collection.IndexOf( testClause );
' Tests for the presence of a CodeCatchClause in the 
' collection, and retrieves its index if it is found.
Dim testClause As New CodeCatchClause("e")
Dim itemIndex As Integer = -1
If collection.Contains(testClause) Then
    itemIndex = collection.IndexOf(testClause)
End If

適用於

另請參閱