Bagikan melalui


CodeAttributeDeclarationCollection.IndexOf(CodeAttributeDeclaration) Metode

Definisi

Mendapatkan indeks objek yang ditentukan CodeAttributeDeclaration dalam koleksi, jika ada dalam koleksi.

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

Parameter

value
CodeAttributeDeclaration

Objek CodeAttributeDeclaration yang akan ditemukan dalam koleksi.

Mengembalikan

Indeks dalam kumpulan objek yang ditentukan, jika ditemukan; jika tidak, -1.

Contoh

Contoh berikut mencari keberadaan instans tertentu CodeAttributeDeclaration dan menggunakan metode untuk mendapatkan nilai indeks tempat instans IndexOf ditemukan.

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

Berlaku untuk

Lihat juga