Share via


CompilerErrorCollection.IndexOf(CompilerError) Método

Definição

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

public:
 int IndexOf(System::CodeDom::Compiler::CompilerError ^ value);
public int IndexOf (System.CodeDom.Compiler.CompilerError value);
member this.IndexOf : System.CodeDom.Compiler.CompilerError -> int
Public Function IndexOf (value As CompilerError) As Integer

Parâmetros

value
CompilerError

O CompilerError a ser localizado.

Retornos

O índice do CompilerError especificado no CompilerErrorCollection, se encontrado; caso contrário, -1.

Exemplos

O exemplo a seguir pesquisa um objeto específico CompilerError e usa o IndexOf método para determinar o valor de índice no qual ele foi encontrado.

// Tests for the presence of a CompilerError in the
// collection, and retrieves its index if it is found.
CompilerError^ testError = gcnew CompilerError( "Testfile.cs",5,10,"CS0001","Example error text" );
int itemIndex = -1;
if ( collection->Contains( testError ) )
   itemIndex = collection->IndexOf( testError );
// Tests for the presence of a CompilerError in the
// collection, and retrieves its index if it is found.
CompilerError testError = new CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text");
int itemIndex = -1;
if( collection.Contains( testError ) )
    itemIndex = collection.IndexOf( testError );
' Tests for the presence of a CompilerError in the 
' collection, and retrieves its index if it is found.
Dim testError As New CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text")
Dim itemIndex As Integer = -1
If collection.Contains(testError) Then
    itemIndex = collection.IndexOf(testError)
End If

Aplica-se a

Confira também