Язык

ParserErrorCollection.IndexOf(ParserError) Метод

Определение

Возвращает индекс указанного ParserError объекта в коллекции.

public:
 int IndexOf(System::Web::ParserError ^ value);
public int IndexOf(System.Web.ParserError value);
member this.IndexOf : System.Web.ParserError -> int
Public Function IndexOf (value As ParserError) As Integer

Параметры

value
ParserError

Расположение ParserError в коллекции.

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

Отсчитываемый от нуля индекс ParserError объектов в коллекции; в противном случае — значение 1, если он ParserError не находится в коллекции.

Примеры

В следующем примере кода показано, как найти индекс объекта по указанному индексу ParserErrorParserErrorCollection в коллекции.

// Test for the presence of a ParserError in the 
// collection, and retrieve its index if it is found.
ParserError testError = new ParserError("Error", "Path", 1);
int itemIndex = -1;
if (collection.Contains(testError))
  itemIndex = collection.IndexOf(testError);
' Test for the presence of a ParserError in the 
' collection, and retrieve its index if it is found.
Dim testError As New ParserError("Error", "Path", 1)
Dim itemIndex As Integer = -1
If collection.Contains(testError) Then
  itemIndex = collection.IndexOf(testError)
End If

Комментарии

IndexOf Используйте метод для определения индекса ParserError объекта в коллекции. Это полезно, чтобы определить индекс каждого из них ParserError при итерации по коллекции с помощью объекта, IEnumerator возвращаемого методом GetEnumerator .

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