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

适用于

另请参阅