SiteMapNodeCollection.AddRange 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將一組 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[]
要加入至目前 SiteMapNode 中之 SiteMapNodeCollection 型別陣列。
例外狀況
value
為 null
。
備註
傳遞至 方法的 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 物件。
例外狀況
value
為 null
。
範例
下列程式碼範例示範如何建立可 SiteMapNodeCollection 修改的集合,然後使用 方法將物件加入 SiteMapNode 其中 AddRange 。
// 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 集合可以包含 null
SiteMapNode 物件;不過,這會導致操作 時 SiteMapNodeCollection 發生非預期的例外狀況。
您無法將 SiteMapNode 物件加入唯讀或固定大小 。 SiteMapNodeCollection 您可以藉由檢查 屬性來 IsReadOnly 測試 是否 SiteMapNodeCollection 為唯讀。