Share via


ParserErrorCollection.Contains(ParserError) メソッド

定義

ParserError オブジェクトがコレクション内にあるかどうかを判断します。

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

パラメーター

value
ParserError

コレクション内で検索する ParserError

戻り値

ParserError がコレクション内に存在する場合は true。それ以外の場合は false

次のコード例では、オブジェクト内の指定した ParserError オブジェクトのインスタンスを検索する方法を ParserErrorCollection 示します。

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

注釈

同じ ParserError オブジェクトをコレクションに複数回追加することはできません。 ただし、オブジェクトを複数回追加 ParserError しようとすると、例外はスローされません。 代わりに、追加は失敗します。 この場合、 Add メソッドは -1 の値を返します。 ただし、 AddRange メソッドと Insert メソッドには戻り値がありません。 これらのメソッドのいずれかを使用してオブジェクトを追加 ParserError する場合は、 メソッドを Contains 使用して、特定 ParserError のオブジェクトが既にコレクション内にあるかどうかを判断します。

適用対象