CodeExpressionCollection.IndexOf(CodeExpression) Metodo

Definizione

Ottiene l'indice dell'oggetto specificato CodeExpression nell'insieme, se presente nell'insieme.

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

Parametri

value
CodeExpression

Oggetto CodeExpression da individuare nell'insieme.

Valori restituiti

Indice dell'oggetto specificato, se trovato, nell'insieme; in caso contrario, -1.

Esempio

Nell'esempio seguente viene eseguita la ricerca della presenza di un oggetto specifico CodeExpression e viene utilizzato il IndexOf metodo per ottenere il valore di indice in corrispondenza del quale è stato trovato.

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

Si applica a

Vedi anche