Поделиться через


CompilerErrorCollection.IndexOf(CompilerError) Метод

Определение

Получает индекс в коллекции указанного объекта CompilerError, если он существует в коллекции.

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

Параметры

value
CompilerError

Искомый объект CompilerError.

Возвращаемое значение

Индекс указанного объекта CompilerError в CompilerErrorCollection, если он найден; в противном случае — значение -1.

Примеры

В следующем примере выполняется поиск определенного CompilerError объекта и используется IndexOf метод для определения значения индекса, по которому он был найден.

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

Применяется к

См. также раздел