Udostępnij za pośrednictwem


ParserErrorCollection.IndexOf(ParserError) Metoda

Definicja

Pobiera indeks określonego ParserError obiektu w kolekcji.

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

Parametry

value
ParserError

Element ParserError do zlokalizowania w kolekcji.

Zwraca

Int32

Indeks ParserError obiektów w kolekcji oparty na zera; w przeciwnym razie 1, jeśli ParserError nie znajduje się w kolekcji.

Przykłady

Poniższy przykład kodu pokazuje, jak zlokalizować indeks ParserError obiektu w określonym indeksie ParserErrorCollection w kolekcji.

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

Uwagi

IndexOf Użyj metody , aby określić indeks ParserError obiektu w kolekcji. Jest to przydatne do określenia indeksu każdej ParserError z nich podczas iterowania przez kolekcję przy użyciu IEnumerator obiektu zwróconego przez metodę GetEnumerator .

Dotyczy