CompilerErrorCollection.IndexOf(CompilerError) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取集合中指定 CompilerError 对象的索引(如果集合中存在)。
public:
int IndexOf(System::CodeDom::Compiler::CompilerError ^ value);
public int IndexOf(System.CodeDom.Compiler.CompilerError value);
member this.IndexOf : System.CodeDom.Compiler.CompilerError -> int
Public Function IndexOf (value As CompilerError) As Integer
参数
- value
- CompilerError
要 CompilerError 查找的。
返回
如果找到,CompilerError则为指定的CompilerErrorCollection索引;否则为 -1。
示例
以下示例搜索特定 CompilerError 对象,并使用 IndexOf 该方法确定找到它的索引值。
// Tests for the presence of a CompilerError in the
// collection, and retrieves its index if it is found.
CompilerError testError = new CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text");
int itemIndex = -1;
if( collection.Contains( testError ) )
itemIndex = collection.IndexOf( testError );
' Tests for the presence of a CompilerError in the
' collection, and retrieves its index if it is found.
Dim testError As New CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text")
Dim itemIndex As Integer = -1
If collection.Contains(testError) Then
itemIndex = collection.IndexOf(testError)
End If