CompilerErrorCollection.Contains(CompilerError) 方法

定義

取得值,這個值表示集合是否包含指定的 CompilerError 物件。

C#
public bool Contains (System.CodeDom.Compiler.CompilerError value);

參數

value
CompilerError

要尋找的 CompilerError

傳回

如果 CompilerError 包含在集合裡,則為 true,否則為 false

範例

下列範例會 Contains 使用 方法來找出特定 CompilerError 物件,並判斷找到它的索引值。

C#
// 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 );

適用於

產品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

另請參閱