CompilerErrorCollection.IndexOf(CompilerError) 方法

定义

获取集合中指定 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

适用于

另请参阅