Compartir a través de


CodeExpressionCollection.IndexOf(CodeExpression) Método

Definición

Obtiene el índice del objeto CodeExpression especificado en la colección, si existe en la colección.

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

Parámetros

value
CodeExpression

Objeto CodeExpression que se va a buscar en la colección.

Devoluciones

Índice del objeto especificado, si se encuentra en la colección; de lo contrario, -1.

Ejemplos

En el ejemplo siguiente se busca la presencia de un objeto específico CodeExpression y se usa el IndexOf método para obtener el valor de índice en el que se encontró.

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

Se aplica a

Consulte también