Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
AddRange Method (CodeStatementCollection)
Collapse the table of content
Expand the table of content

CodeStatementCollection.AddRange Method (CodeStatementCollection)

Adds the contents of another CodeStatementCollection object to the end of the collection.

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

public void AddRange(
	CodeStatementCollection value
)

Parameters

value
Type: System.CodeDom.CodeStatementCollection

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

ExceptionCondition
ArgumentNullException

value is null.

The following example demonstrates how to use the AddRange(CodeStatementCollection) method overload to add the members of one CodeStatementCollection to another.

// 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

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft