CodeStatementCollection.AddRange Method

Definition

Adds a set of CodeStatement objects to the collection.

Overloads

AddRange(CodeStatement[])

Adds a set of CodeStatement objects to the collection.

AddRange(CodeStatementCollection)

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

AddRange(CodeStatement[])

Source:
CodeStatementCollection.cs
Source:
CodeStatementCollection.cs
Source:
CodeStatementCollection.cs
Source:
CodeStatementCollection.cs

Adds a set of CodeStatement objects to the collection.

public void AddRange (System.CodeDom.CodeStatement[] value);

Parameters

value
CodeStatement[]

An array of CodeStatement objects to add to the collection.

Exceptions

value is null.

Examples

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 );

See also

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

AddRange(CodeStatementCollection)

Source:
CodeStatementCollection.cs
Source:
CodeStatementCollection.cs
Source:
CodeStatementCollection.cs
Source:
CodeStatementCollection.cs

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

public void AddRange (System.CodeDom.CodeStatementCollection value);

Parameters

value
CodeStatementCollection

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

Exceptions

value is null.

Examples

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 );

See also

Applies to

.NET 9 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9