ParserErrorCollection.IndexOf(ParserError) Metódus

Definíció

Lekéri a gyűjteményben megadott ParserError objektum indexét.

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

Paraméterek

value
ParserError

A ParserError gyűjteményben keresendő.

Válaszok

A gyűjteményen belüli objektumok nulla alapú indexe ParserError , ellenkező esetben 1, ha az ParserError nem szerepel a gyűjteményben.

Példák

Az alábbi példakód bemutatja, hogyan lehet megkeresni egy ParserError objektum indexét a megadott indexben egy ParserErrorCollection gyűjteményben.

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

Megjegyzések

A metódussal IndexOf meghatározhatja egy objektum indexét ParserError a gyűjteményen belül. Ez hasznos lehet az egyes ParserError objektumok indexének meghatározásához, amikor a metódus által IEnumerator visszaadott objektummal GetEnumerator iterálja a gyűjteményt.

A következőre érvényes: