CodeAttributeDeclarationCollection.IndexOf(CodeAttributeDeclaration) メソッド

定義

コレクション内に指定した CodeAttributeDeclaration オブジェクトが存在する場合は、そのオブジェクトのインデックスを取得します。

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

パラメーター

value
CodeAttributeDeclaration

コレクション内で検索する CodeAttributeDeclaration オブジェクト。

返品

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

次の例では、特定の CodeAttributeDeclaration インスタンスの存在を検索し、 IndexOf メソッドを使用して、見つかったインデックス値を取得します。

// Tests for the presence of a CodeAttributeDeclaration in
// the collection, and retrieves its index if it is found.
CodeAttributeDeclaration testdeclaration = new CodeAttributeDeclaration("DescriptionAttribute", new CodeAttributeArgument(new CodePrimitiveExpression("Test Description")) );
int itemIndex = -1;
if( collection.Contains( testdeclaration ) )
    itemIndex = collection.IndexOf( testdeclaration );
' Tests for the presence of a CodeAttributeDeclaration in the 
' collection, and retrieves its index if it is found.
Dim testdeclaration As New CodeAttributeDeclaration("DescriptionAttribute", New CodeAttributeArgument(New CodePrimitiveExpression("Test Description")))
Dim itemIndex As Integer = -1
If collection.Contains(testdeclaration) Then
    itemIndex = collection.IndexOf(testdeclaration)
End If

適用対象

こちらもご覧ください