CodeAttributeArgumentCollection.IndexOf(CodeAttributeArgument) 方法

定义

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

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

参数

value
CodeAttributeArgument

要在集合中定位的 CodeAttributeArgument 对象。

返回

Int32

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

示例

以下示例搜索特定 CodeAttributeArgument 对象的存在,并使用 IndexOf 该方法获取找到它的索引值。

// Tests for the presence of a CodeAttributeArgument 
// within the collection, and retrieves its index if it is found.
CodeAttributeArgument^ testArgument = gcnew CodeAttributeArgument( "Test Boolean Argument",gcnew CodePrimitiveExpression( true ) );
int itemIndex = -1;
if ( collection->Contains( testArgument ) )
   itemIndex = collection->IndexOf( testArgument );
// Tests for the presence of a CodeAttributeArgument
// within the collection, and retrieves its index if it is found.
CodeAttributeArgument testArgument = new CodeAttributeArgument("Test Boolean Argument", new CodePrimitiveExpression(true));
int itemIndex = -1;
if( collection.Contains( testArgument ) )
    itemIndex = collection.IndexOf( testArgument );
' Tests for the presence of a CodeAttributeArgument in 
' the collection, and retrieves its index if it is found.
Dim testArgument As New CodeAttributeArgument("Test Boolean Argument", New CodePrimitiveExpression(True))
Dim itemIndex As Integer = -1
If collection.Contains(testArgument) Then
    itemIndex = collection.IndexOf(testArgument)
End If

适用于

另请参阅