Bagikan melalui


CodeStatementCollection.IndexOf(CodeStatement) Metode

Definisi

Mendapatkan indeks objek yang ditentukan CodeStatement di CodeStatementCollection, jika ada dalam koleksi.

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

Parameter

value
CodeStatement

untuk CodeStatement menemukan dalam koleksi.

Mengembalikan

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

Contoh

Contoh berikut mencari keberadaan tertentu CodeStatement dan menggunakan IndexOf metode untuk mengambil nilai indeks tempatnya ditemukan.

// Tests for the presence of a CodeStatement in the 
// collection, and retrieves its index if it is found.
int itemIndex = -1;
if ( collection->Contains( testStatement ) )
   itemIndex = collection->IndexOf( testStatement );
// Tests for the presence of a CodeStatement in the
// collection, and retrieves its index if it is found.
int itemIndex = -1;
if( collection.Contains( testStatement ) )
    itemIndex = collection.IndexOf( testStatement );
' Tests for the presence of a CodeStatement in the 
' collection, and retrieves its index if it is found.
Dim itemIndex As Integer = -1
If collection.Contains(testStatement) Then
    itemIndex = collection.IndexOf(testStatement)
End If

Berlaku untuk

Lihat juga