CodeParameterDeclarationExpressionCollection.IndexOf 方法

定义

获取指定的 CodeParameterDeclarationExpression 在该集合中的索引(如果它在该集合中存在)。

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

参数

返回

如果在该集合中找到指定对象,则为此对象在该集合中的索引;否则为 -1。

示例

以下示例搜索是否存在特定 CodeParameterDeclarationExpression 实例,并使用 IndexOf 方法获取找到它的索引值。

// Tests for the presence of a CodeParameterDeclarationExpression 
// in the collection, and retrieves its index if it is found.
CodeParameterDeclarationExpression^ testParameter = gcnew CodeParameterDeclarationExpression( int::typeid,"testIntArgument" );
int itemIndex = -1;
if ( collection->Contains( testParameter ) )
   itemIndex = collection->IndexOf( testParameter );
// Tests for the presence of a CodeParameterDeclarationExpression
// in the collection, and retrieves its index if it is found.
CodeParameterDeclarationExpression testParameter = new CodeParameterDeclarationExpression(typeof(int), "testIntArgument");
int itemIndex = -1;
if( collection.Contains( testParameter ) )
    itemIndex = collection.IndexOf( testParameter );
' Tests for the presence of a CodeParameterDeclarationExpression 
' in the collection, and retrieves its index if it is found.
Dim testParameter As New CodeParameterDeclarationExpression(GetType(Integer), "testIntArgument")
Dim itemIndex As Integer = -1
If collection.Contains(testParameter) Then
    itemIndex = collection.IndexOf(testParameter)
End If

适用于

另请参阅