CodeStatementCollection.IndexOf(CodeStatement) 方法

定义

获取集合中CodeStatement指定CodeStatementCollection对象的索引(如果该对象存在于集合中)。

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

适用于

另请参阅