CompilerErrorCollection.IndexOf(CompilerError) Metodo

Definizione

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

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

Parametri

value
CompilerError

Oggetto CompilerError da individuare.

Valori restituiti

Indice dell'oggetto specificato CompilerError in CompilerErrorCollection, se trovato; in caso contrario, -1.

Esempio

Nell'esempio seguente viene eseguita la ricerca di un oggetto specifico CompilerError e viene utilizzato il IndexOf metodo per determinare il valore di indice in corrispondenza del quale è stato trovato.

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

Si applica a

Vedi anche