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 オブジェクト。

返品

コレクション内の指定したオブジェクトのインデックス (見つかった場合)。それ以外の場合は -1。

次の例では、特定の CodeAttributeArgument オブジェクトの存在を検索し、 IndexOf メソッドを使用して、検出されたインデックス値を取得します。

// 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

適用対象

こちらもご覧ください