CodeTypeMemberCollection.AddRange Method (CodeTypeMemberCollection)


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

Adds the contents of another CodeTypeMemberCollection to the end of the collection.

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

public void AddRange(
	CodeTypeMemberCollection value


Type: System.CodeDom.CodeTypeMemberCollection

A CodeTypeMemberCollection containing the objects to add to the collection.

Exception Condition

value is null.

The following code example demonstrates how to use the two AddRange method overloads to add the members of an array to a CodeTypeMemberCollection object, and to add the members of one CodeTypeMemberCollection to another.

// Adds an array of CodeTypeMember objects to the collection.
CodeTypeMember[] members = { new CodeMemberField("System.String", "TestStringField1"), new CodeMemberField("System.String", "TestStringField2") };
collection.AddRange( members );

// Adds a collection of CodeTypeMember objects to the collection.
CodeTypeMemberCollection membersCollection = new CodeTypeMemberCollection();
membersCollection.Add( new CodeMemberField("System.String", "TestStringField1") );
membersCollection.Add( new CodeMemberField("System.String", "TestStringField2") );
collection.AddRange( membersCollection );

.NET Framework
Available since 1.1
Return to top