CompilerErrorCollection.IndexOf Method (CompilerError)

 

Gets the index of the specified CompilerError object in the collection, if it exists in the collection.

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

public int IndexOf(
	CompilerError value
)

Parameters

value
Type: System.CodeDom.Compiler.CompilerError

The CompilerError to locate.

Return Value

Type: System.Int32

The index of the specified CompilerError in the CompilerErrorCollection, if found; otherwise, -1.

The following example searches for a specific CompilerError object and uses the IndexOf method to 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
Show: