Share via


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

戻り値

指定した CompilerErrorCompilerErrorCollection 内に存在する場合は、そのインデックス。それ以外の場合は -1。

次の例では、特定 CompilerError のオブジェクトを検索し、 メソッドを IndexOf 使用して、検出されたインデックス値を決定します。

// Tests for the presence of a CompilerError in the
// collection, and retrieves its index if it is found.
CompilerError^ testError = gcnew 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.
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

適用対象

こちらもご覧ください