Redigera

Dela via


SiteMapNodeCollection.AddRange Method

Definition

Adds a set of SiteMapNode objects to the collection.

Overloads

AddRange(SiteMapNode[])

Adds an array of type SiteMapNode to the collection.

AddRange(SiteMapNodeCollection)

Adds the nodes in the specified SiteMapNodeCollection to the current collection.

AddRange(SiteMapNode[])

Adds an array of type SiteMapNode to the collection.

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())

Parameters

value
SiteMapNode[]

An array of type SiteMapNode to add to the current SiteMapNodeCollection.

Exceptions

value is null.

Remarks

The array that is passed to the AddRange method can contain null values; however, this leads to unexpected exceptions when the SiteMapNodeCollection collection is manipulated.

You cannot add a SiteMapNode object to a read-only or fixed-size SiteMapNodeCollection. You can test whether a SiteMapNodeCollection is read-only by checking the IsReadOnly property.

See also

Applies to

AddRange(SiteMapNodeCollection)

Adds the nodes in the specified SiteMapNodeCollection to the current collection.

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)

Parameters

value
SiteMapNodeCollection

A SiteMapNodeCollection that contains the SiteMapNode objects to add to the current SiteMapNodeCollection.

Exceptions

value is null.

Examples

The following code example demonstrates how to create a modifiable SiteMapNodeCollection collection, and then add SiteMapNode objects to it using the AddRange method.


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

Remarks

The SiteMapNodeCollection collection that is passed to the AddRange method can contain null SiteMapNode objects; however, this leads to unexpected exceptions when the SiteMapNodeCollection is manipulated.

You cannot add a SiteMapNode object to a read-only or fixed-size SiteMapNodeCollection. You can test whether a SiteMapNodeCollection is read-only by checking the IsReadOnly property.

See also

Applies to