ParserErrorCollection.Contains(ParserError) Yöntem

Tanım

Nesnenin ParserError koleksiyonda bulunup bulunmadığını belirler.

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

Parametreler

value
ParserError

ParserError koleksiyonda bulmak için.

Döndürülenler

true ParserError koleksiyonundaysa; değilse, false.

Örnekler

Aşağıdaki kod örneği, bir nesnede ParserError belirtilen ParserErrorCollection bir nesnenin örneğinin nasıl aranacaklarını gösterir.

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

Açıklamalar

Aynı ParserError nesneyi koleksiyona birden çok kez ekleyemezsiniz. Ancak, bir ParserError nesneyi birden çok kez eklemeye çalışmak bir özel durum oluşturmaz. Bunun yerine, ekleme başarısız olur. Bu durumda, Add yöntemi -1 değerini döndürür. Ancak ve AddRange yöntemlerinin Insert dönüş değerleri yoktur. Bu yöntemlerden birini kullanarak nesneleri eklerkenParserError, belirli Contains bir nesnenin ParserError koleksiyonda zaten olup olmadığını belirlemek için yöntemini kullanın.

Şunlara uygulanır