Sdílet prostřednictvím


CodeAttributeDeclarationCollection.IndexOf(CodeAttributeDeclaration) Metoda

Definice

Získá index zadaného CodeAttributeDeclaration objektu v kolekci, pokud existuje v kolekci.

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

Parametry

value
CodeAttributeDeclaration

Objekt CodeAttributeDeclaration , který se má v kolekci najít.

Návraty

Index v kolekci zadaného objektu, pokud je nalezen; v opačném případě -1.

Příklady

Následující příklad vyhledá přítomnost konkrétní CodeAttributeDeclaration instance a použije metodu IndexOf k získání hodnoty indexu, ve které byla nalezena.

// Tests for the presence of a CodeAttributeDeclaration in 
// the collection, and retrieves its index if it is found.
array<CodeAttributeArgument^>^temp3 = {gcnew CodeAttributeArgument( gcnew CodePrimitiveExpression( "Test Description" ) )};
CodeAttributeDeclaration^ testdeclaration = gcnew CodeAttributeDeclaration( "DescriptionAttribute",temp3 );
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.
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

Platí pro

Viz také