SiteMapNodeCollection.AddRange 方法

定义

向集合添加一组 SiteMapNode 对象。

重载

AddRange(SiteMapNode[])

向集合添加 SiteMapNode 类型的数组。

AddRange(SiteMapNodeCollection)

将指定的 SiteMapNodeCollection 中的节点添加到当前集合。

AddRange(SiteMapNode[])

向集合添加 SiteMapNode 类型的数组。

public:
 virtual void AddRange(cli::array <System::Web::SiteMapNode ^> ^ value);
public virtual void AddRange (System.Web.SiteMapNode[] value);
abstract member AddRange : System.Web.SiteMapNode[] -> unit
override this.AddRange : System.Web.SiteMapNode[] -> unit
Public Overridable Sub AddRange (value As SiteMapNode())

参数

value
SiteMapNode[]

要添加到当前 SiteMapNodeSiteMapNodeCollection 类型的数组。

例外

valuenull

注解

传递给 AddRange 该方法的数组可以包含 null 值;但是,当操作集合时 SiteMapNodeCollection ,这会导致意外异常。

不能将 SiteMapNode 对象添加到只读或固定大小 SiteMapNodeCollection。 可以通过检查IsReadOnly属性来测试某个属性SiteMapNodeCollection是否为只读。

另请参阅

适用于

AddRange(SiteMapNodeCollection)

将指定的 SiteMapNodeCollection 中的节点添加到当前集合。

public:
 virtual void AddRange(System::Web::SiteMapNodeCollection ^ value);
public virtual void AddRange (System.Web.SiteMapNodeCollection value);
abstract member AddRange : System.Web.SiteMapNodeCollection -> unit
override this.AddRange : System.Web.SiteMapNodeCollection -> unit
Public Overridable Sub AddRange (value As SiteMapNodeCollection)

参数

value
SiteMapNodeCollection

一个 SiteMapNodeCollection,它包含要添加到当前 SiteMapNode 中的 SiteMapNodeCollection 对象。

例外

valuenull

示例

下面的代码示例演示如何创建可SiteMapNodeCollection修改的集合,然后使用该方法向其AddRange添加SiteMapNode对象。


// Create a SiteMapNodeCollection with all the nodes
// from the first two hierarchical levels of the current
// site map.
SiteMapNodeCollection baseCollection =
    new SiteMapNodeCollection(SiteMap.RootNode);

SiteMapNodeCollection childCollection =
    SiteMap.RootNode.ChildNodes;

baseCollection.AddRange(childCollection);

Response.Write( "<BR>Derived SiteMapNodeCollection.<BR><HR><BR>");
foreach (SiteMapNode node in baseCollection) {
    Response.Write( node.Title + "<BR>");
}

' Create a SiteMapNodeCollection with all the nodes
' from the first two hierarchical levels of the current
' site map.
Dim baseCollection As SiteMapNodeCollection
baseCollection = New SiteMapNodeCollection(SiteMap.RootNode)

Dim childCollection As SiteMapNodeCollection = SiteMap.RootNode.ChildNodes

baseCollection.AddRange(childCollection)

Response.Write( "<BR>Derived SiteMapNodeCollection.<BR><HR><BR>")

For Each node In baseCollection
    Response.Write( node.Title + "<BR>")
Next

注解

SiteMapNodeCollection传递给AddRange方法的集合可以包含SiteMapNodenull对象;但是,这会导致操作时SiteMapNodeCollection出现意外异常。

不能将 SiteMapNode 对象添加到只读或固定大小 SiteMapNodeCollection。 可以通过检查IsReadOnly属性来测试某个属性SiteMapNodeCollection是否为只读。

另请参阅

适用于