ParserErrorCollection.Contains(ParserError) Metodo

Definizione

Consente di determinare se l'oggetto ParserError è contenuto 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.

Restituisce

true se l'oggetto ParserError è 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 lo stesso ParserError oggetto all'insieme più di una volta. Tuttavia, il tentativo di aggiungere un ParserError oggetto più di una volta non genererà un'eccezione. Invece, l'aggiunta avrà esito negativo. In questo caso, il Add metodo restituirà un valore pari a -1. Tuttavia, i metodi e Insert non hanno valori restituitiAddRange. Quando si aggiungono ParserError oggetti usando uno di questi metodi, usare il Contains metodo per determinare se un particolare ParserError oggetto è già presente nell'insieme.

Si applica a