Share via


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 koleksiyonunda bulun.

Döndürülenler

trueParserError koleksiyonundaysa; değilse, false.

Örnekler

Aşağıdaki kod örneği, bir nesnede ParserErrorCollection belirtilen ParserError nesnenin örneğinin nasıl aranduğunu 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 ö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 Insert yöntemlerinin AddRange dönüş değerleri yoktur. Bu yöntemlerden birini kullanarak nesneleri eklerkenParserError, belirli ParserError bir nesnenin Contains koleksiyonda zaten olup olmadığını belirlemek için yöntemini kullanın.

Şunlara uygulanır