CodeStatementCollection.IndexOf(CodeStatement) メソッド

定義

コレクション内に存在する場合は、CodeStatementCollection内の指定したCodeStatement オブジェクトのインデックスを取得します。

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

パラメーター

value
CodeStatement

コレクション内で検索する CodeStatement

返品

指定したオブジェクトが見つかった場合は、コレクション内のインデックス。それ以外の場合は -1。

次の例では、特定の CodeStatement の存在を検索し、 IndexOf メソッドを使用して、検出されたインデックス値を取得します。

// Tests for the presence of a CodeStatement in the
// collection, and retrieves its index if it is found.
int itemIndex = -1;
if( collection.Contains( testStatement ) )
    itemIndex = collection.IndexOf( testStatement );
' Tests for the presence of a CodeStatement in the 
' collection, and retrieves its index if it is found.
Dim itemIndex As Integer = -1
If collection.Contains(testStatement) Then
    itemIndex = collection.IndexOf(testStatement)
End If

適用対象

こちらもご覧ください