ParserErrorCollection.IndexOf(ParserError) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取集合中指定 ParserError 对象的索引。
public:
int IndexOf(System::Web::ParserError ^ value);
public int IndexOf(System.Web.ParserError value);
member this.IndexOf : System.Web.ParserError -> int
Public Function IndexOf (value As ParserError) As Integer
参数
- value
- ParserError
在 ParserError 集合中查找的项。
返回
集合中对象的从零开始的 ParserError 索引;否则为 1(如果 ParserError 集合中不存在)。
示例
下面的代码示例演示如何在集合中的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
注解
IndexOf使用该方法确定集合中对象的索引ParserError。 这可用于使用ParserError方法返回IEnumerator的对象循环访问集合时确定每个GetEnumerator对象的索引。