Share via


CodeStatementCollection.IndexOf(CodeStatement) Méthode

Définition

Obtient l'index de l'objet CodeStatement spécifié dans la CodeStatementCollection, s'il existe dans la collection.

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

Paramètres

value
CodeStatement

CodeStatement à rechercher dans la collection.

Retours

Index de l'objet spécifié, s'il existe, dans la collection ; sinon, -1.

Exemples

L’exemple suivant recherche la présence d’un spécifique CodeStatement et utilise la IndexOf méthode pour récupérer la valeur d’index à laquelle il a été trouvé.

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

S’applique à

Voir aussi