CompilerErrorCollection.AddRange Method (CompilerErrorCollection)

 

Adds the contents of the specified compiler error collection to the end of the error collection.

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

public void AddRange(
	CompilerErrorCollection value
)

Parameters

value
Type: System.CodeDom.Compiler.CompilerErrorCollection

A CompilerErrorCollection object that contains the objects to add to the collection.

Exception Condition
ArgumentNullException

value is null.

The following example demonstrates how to use the AddRange(CompilerErrorCollection) method overload to add CompilerError objects from one CompilerErrorCollection to another CompilerErrorCollection.

// Adds an array of CompilerError objects to the collection.
CompilerError[] errors = { new CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text"), new CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text") };
collection.AddRange( errors );

// Adds a collection of CompilerError objects to the collection.
CompilerErrorCollection errorsCollection = new CompilerErrorCollection();
errorsCollection.Add( new CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text") );
errorsCollection.Add( new CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text") );
collection.AddRange( errorsCollection );

.NET Framework
Available since 1.1
Return to top
Show: