CodeStatementCollection.IndexOf(CodeStatement) Metodo

Definizione

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

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

Parametri

value
CodeStatement

Oggetto CodeStatement da individuare nella raccolta.

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 CodeStatement e viene utilizzato il IndexOf metodo per recuperare il valore di indice in corrispondenza del quale è stato trovato.

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

Si applica a

Vedi anche