CodeStatementCollection.AddRange 方法

定义

向集合添加一组 CodeStatement 对象。

重载

AddRange(CodeStatement[])

向集合添加一组 CodeStatement 对象。

AddRange(CodeStatementCollection)

将另一个 CodeStatementCollection 对象的内容添加到集合的末尾。

AddRange(CodeStatement[])

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

向集合添加一组 CodeStatement 对象。

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

参数

value
CodeStatement[]

要添加到集合中的 CodeStatement 对象的数组。

例外

valuenull

示例

以下示例演示如何使用 AddRange(CodeStatement[]) 方法重载将数组的成员添加到 CodeStatementCollection 实例。

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

另请参阅

适用于

AddRange(CodeStatementCollection)

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

将另一个 CodeStatementCollection 对象的内容添加到集合的末尾。

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

参数

value
CodeStatementCollection

一个 CodeStatementCollection 对象,其中包含要添加到集合中的对象。

例外

valuenull

示例

以下示例演示如何使用 AddRange(CodeStatementCollection) 方法重载将一个成员添加到另一个 CodeStatementCollection 成员。

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

另请参阅

适用于