CodeExpressionCollection.IndexOf(CodeExpression) Methode

Definition

Ruft den Index des angegebenen CodeExpression-Objekts in der Auflistung ab, sofern es in der Auflistung vorhanden ist.

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

Parameter

value
CodeExpression

Das CodeExpression-Objekt, das in der Auflistung gesucht werden soll.

Gibt zurück

Der Index des angegebenen Objekts in der Auflistung, sofern gefunden, andernfalls -1.

Beispiele

Das folgende Beispiel sucht nach dem Vorhandensein eines bestimmten CodeExpression Objekts und verwendet die IndexOf -Methode, um den Indexwert abzurufen, an dem es gefunden wurde.

// Tests for the presence of a CodeExpression in the 
// collection, and retrieves its index if it is found.
CodeExpression^ testComment = gcnew 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.
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

Gilt für:

Weitere Informationen