CodeExpressionCollection.IndexOf(CodeExpression) メソッド

定義

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

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

パラメーター

value
CodeExpression

コレクション内で検索する CodeExpression オブジェクト。

戻り値

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

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

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

適用対象

こちらもご覧ください