CodeStatementCollection.AddRange Method (CodeStatement[])

 

Adds a set of CodeStatement objects to the collection.

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

public void AddRange(
	CodeStatement[] value
)

Parameters

value
Type: System.CodeDom.CodeStatement[]

An array of CodeStatement objects to add to the collection.

Exception Condition
ArgumentNullException

value is null.

The following example demonstrates how to use the AddRange(CodeStatement[]) method overload to add the members of an array to a CodeStatementCollection instance.

// Adds an array of CodeStatement objects to the collection.
CodeStatement[] statements = { 
                new CodeCommentStatement("Test comment statement"), 
                new CodeCommentStatement("Test comment statement")};
collection.AddRange( statements );

// Adds a collection of CodeStatement objects to the collection.
CodeStatement testStatement = new CodeCommentStatement("Test comment statement");
CodeStatementCollection statementsCollection = new CodeStatementCollection();
statementsCollection.Add( new CodeCommentStatement("Test comment statement") );
statementsCollection.Add( new CodeCommentStatement("Test comment statement") );
statementsCollection.Add( testStatement );

collection.AddRange( statementsCollection );

.NET Framework
Available since 1.1
Return to top
Show: