CodeStatementCollection.IndexOf(CodeStatement) Metoda

Definice

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

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

Parametry

value
CodeStatement

Chcete-li CodeStatement najít v kolekci.

Návraty

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

Příklady

Následující příklad vyhledá přítomnost konkrétního CodeStatement a použije metodu IndexOf k načtení hodnoty indexu, ve které byla nalezena.

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

Platí pro

Viz také