共用方式為


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 = gcnew 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.
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

適用於

另請參閱