CodeDirectiveCollection.AddRange Method (CodeDirectiveCollection)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

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

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

public void AddRange(
	CodeDirectiveCollection value


Type: System.CodeDom.CodeDirectiveCollection

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

Exception Condition

value is null.

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.

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

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

.NET Framework
Available since 2.0
Return to top