CodeCommentStatementCollection.IndexOf(CodeCommentStatement) メソッド

定義

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

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

パラメーター

value
CodeCommentStatement

検索する CodeCommentStatement オブジェクト。

返品

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

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

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

適用対象

こちらもご覧ください