ParserErrorCollection.Contains(ParserError) Metodo

Definizione

Determina se l'oggetto ParserError si trova nell'insieme.

public:
 bool Contains(System::Web::ParserError ^ value);
public bool Contains(System.Web.ParserError value);
member this.Contains : System.Web.ParserError -> bool
Public Function Contains (value As ParserError) As Boolean

Parametri

value
ParserError

Oggetto ParserError da individuare nella raccolta.

Valori restituiti

true se è ParserError presente nell'insieme; in caso contrario, false.

Esempio

Nell'esempio di codice seguente viene illustrato come cercare un'istanza di un oggetto specificato ParserError in un ParserErrorCollection oggetto .

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

Commenti

Non è possibile aggiungere più volte lo stesso ParserError oggetto all'insieme. Tuttavia, il tentativo di aggiungere un ParserError oggetto più volte non genererà un'eccezione. L'aggiunta avrà invece esito negativo. In questo caso, il Add metodo restituirà il valore -1. Tuttavia, i AddRange metodi e Insert non hanno valori restituiti. Quando si aggiungono ParserError oggetti utilizzando uno di questi metodi, utilizzare il Contains metodo per determinare se un particolare ParserError oggetto è già presente nell'insieme.

Si applica a