CompilerErrorCollection.Contains(CompilerError) 方法

定义

获取一个值,该值指示集合是否包含指定的 CompilerError 对象。

public:
 bool Contains(System::CodeDom::Compiler::CompilerError ^ value);
public bool Contains (System.CodeDom.Compiler.CompilerError value);
member this.Contains : System.CodeDom.Compiler.CompilerError -> bool
Public Function Contains (value As CompilerError) As Boolean

参数

value
CompilerError

要查找的 CompilerError

返回

如果 CompilerError 包含在集合中,则为 true;否则为 false

示例

以下示例使用 Contains 方法查找特定 CompilerError 对象并确定找到该对象的索引值。

// 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

适用于

另请参阅