CompilerErrorCollection.Contains Method (CompilerError)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets a value that indicates whether the collection contains the specified CompilerError object.

Namespace:   System.CodeDom.Compiler
Assembly:  System (in System.dll)

public bool Contains(
	CompilerError value


Type: System.CodeDom.Compiler.CompilerError

The CompilerError to locate.

Return Value

Type: System.Boolean

true if the CompilerError is contained in the collection; otherwise, false.

The following example uses the Contains method to locate a specific CompilerError object and determine the index value at which it was found.

// 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
Available since 1.1
Return to top