CodeDirectiveCollection.AddRange Method

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Adds a set of CodeDirective objects to the collection.

Overloads

AddRange(CodeDirective[])

Adds an array of CodeDirective objects to the end of the collection.

AddRange(CodeDirectiveCollection)

Adds the contents of the specified CodeDirectiveCollection object to the end of the collection.

AddRange(CodeDirective[])

Source:
CodeDirectiveCollection.cs
Source:
CodeDirectiveCollection.cs
Source:
CodeDirectiveCollection.cs
Source:
CodeDirectiveCollection.cs
Source:
CodeDirectiveCollection.cs

Adds an array of CodeDirective objects to the end of the collection.

C#
public void AddRange(System.CodeDom.CodeDirective[] value);

Parameters

value
CodeDirective[]

An array of CodeDirective objects to add to the collection.

Exceptions

value is null.

Examples

The following code example shows the use of the AddRange(CodeDirective[]) method to add an array of CodeDirective objects to the collection. This example is part of a larger example provided for the CodeDirectiveCollection class.

C#
// Adds an array of CodeDirective objects to the collection.
CodeDirective[] directives = {
    new CodeRegionDirective(CodeRegionMode.Start,"Region1"),
    new CodeRegionDirective(CodeRegionMode.End,"Region1") };
collection.AddRange(directives);

// Adds a collection of CodeDirective objects to the collection.
CodeDirectiveCollection directivesCollection = new CodeDirectiveCollection();
directivesCollection.Add(new CodeRegionDirective(CodeRegionMode.Start, "Region2"));
directivesCollection.Add(new CodeRegionDirective(CodeRegionMode.End, "Region2"));
collection.AddRange(directivesCollection);

See also

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 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, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

AddRange(CodeDirectiveCollection)

Source:
CodeDirectiveCollection.cs
Source:
CodeDirectiveCollection.cs
Source:
CodeDirectiveCollection.cs
Source:
CodeDirectiveCollection.cs
Source:
CodeDirectiveCollection.cs

Adds the contents of the specified CodeDirectiveCollection object to the end of the collection.

C#
public void AddRange(System.CodeDom.CodeDirectiveCollection value);

Parameters

value
CodeDirectiveCollection

A CodeDirectiveCollection object containing the CodeDirective objects to add to the collection.

Exceptions

value is null.

Examples

The following code example shows the use of the AddRange(CodeDirectiveCollection) method to add the contents of a CodeDirectiveCollection object to the collection. This example is part of a larger example provided for the CodeDirectiveCollection class.

C#
// Adds an array of CodeDirective objects to the collection.
CodeDirective[] directives = {
    new CodeRegionDirective(CodeRegionMode.Start,"Region1"),
    new CodeRegionDirective(CodeRegionMode.End,"Region1") };
collection.AddRange(directives);

// Adds a collection of CodeDirective objects to the collection.
CodeDirectiveCollection directivesCollection = new CodeDirectiveCollection();
directivesCollection.Add(new CodeRegionDirective(CodeRegionMode.Start, "Region2"));
directivesCollection.Add(new CodeRegionDirective(CodeRegionMode.End, "Region2"));
collection.AddRange(directivesCollection);

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 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, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10