Bagikan melalui


CodeTypeDeclarationCollection.IndexOf(CodeTypeDeclaration) Metode

Definisi

Mendapatkan indeks objek yang ditentukan CodeTypeDeclaration di CodeTypeDeclarationCollection, jika ada dalam koleksi.

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

Parameter

value
CodeTypeDeclaration

untuk CodeTypeDeclaration menemukan dalam koleksi.

Mengembalikan

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

Contoh

Contoh berikut mengambil CodeTypeDeclaration entri dari CodeTypeDeclarationCollection objek dan menampilkan nama dan indeks yang dikembalikan oleh IndexOf metode .

// Tests for the presence of a CodeTypeDeclaration in the 
// collection, and retrieves its index if it is found.
CodeTypeDeclaration^ testDeclaration = gcnew CodeTypeDeclaration( "TestType" );
int itemIndex = -1;
if ( collection->Contains( testDeclaration ) )
   itemIndex = collection->IndexOf( testDeclaration );
// Tests for the presence of a CodeTypeDeclaration in the
// collection, and retrieves its index if it is found.
CodeTypeDeclaration testDeclaration = new CodeTypeDeclaration("TestType");
int itemIndex = -1;
if( collection.Contains( testDeclaration ) )
    itemIndex = collection.IndexOf( testDeclaration );
' Tests for the presence of a CodeTypeDeclaration in the 
' collection, and retrieves its index if it is found.
Dim testDeclaration As New CodeTypeDeclaration("TestType")
Dim itemIndex As Integer = -1
If collection.Contains(testDeclaration) Then
    itemIndex = collection.IndexOf(testDeclaration)
End If

Berlaku untuk

Lihat juga