CodeExpressionCollection.IndexOf(CodeExpression) Metoda

Definice

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

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

Parametry

value
CodeExpression

Objekt CodeExpression , který chcete vyhledat v kolekci.

Návraty

Index zadaného objektu, pokud je nalezen, v kolekci; jinak, -1.

Příklady

Následující příklad vyhledá přítomnost konkrétního CodeExpression objektu a použije metodu IndexOf k získání hodnoty indexu, při které byl nalezen.

// Tests for the presence of a CodeExpression in the
// collection, and retrieves its index if it is found.
CodeExpression testComment = new CodePrimitiveExpression(true);
int itemIndex = -1;
if( collection.Contains( testComment ) )
    itemIndex = collection.IndexOf( testComment );
' Tests for the presence of a CodeExpression in the 
' collection, and retrieves its index if it is found.
Dim testComment = New CodePrimitiveExpression(True)
Dim itemIndex As Integer = -1
If collection.Contains(testComment) Then
    itemIndex = collection.IndexOf(testComment)
End If

Platí pro

Viz také