ParserErrorCollection.Contains(ParserError) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
确定对象 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 集合中查找的项。
返回
true 如果集合中为 , ParserError 则为 .;否则为 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 对象是否已在集合中。