Share via


CodeStatementCollection.IndexOf(CodeStatement) Método

Definição

Obtém o índice do objeto CodeStatement na CodeStatementCollection, se ele existe na coleção.

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

Parâmetros

value
CodeStatement

O CodeStatement a ser localizado na coleção.

Retornos

O índice do objeto especificado, se encontrado, na coleção; caso contrário, -1.

Exemplos

O exemplo a seguir pesquisa a presença de um específico CodeStatement e usa o IndexOf método para recuperar o valor de índice no qual ele foi encontrado.

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

Aplica-se a

Confira também