SiteMapNodeCollection SiteMapNodeCollection SiteMapNodeCollection SiteMapNodeCollection Class

定義

提供 SiteMapNode 物件的強類型集合,並實作 IHierarchicalEnumerable 介面以支援整個集合的巡覽。Provides a strongly typed collection for SiteMapNode objects and implements the IHierarchicalEnumerable interface to support navigating through the collection.

public ref class SiteMapNodeCollection : System::Collections::IList, System::Web::UI::IHierarchicalEnumerable
public class SiteMapNodeCollection : System.Collections.IList, System.Web.UI.IHierarchicalEnumerable
type SiteMapNodeCollection = class
    interface IHierarchicalEnumerable
    interface IEnumerable
    interface IList
    interface ICollection
Public Class SiteMapNodeCollection
Implements IHierarchicalEnumerable, IList
繼承
SiteMapNodeCollectionSiteMapNodeCollectionSiteMapNodeCollectionSiteMapNodeCollection
實作

範例

下列程式碼範例示範如何建立SiteMapNodeCollection集合, 然後使用AddRange方法將物件SiteMapNode加入其中。The following code example demonstrates how to create a SiteMapNodeCollection collection, and then add SiteMapNode objects to it using the AddRange method. SiteMapNodeCollection是目前網站地圖的子集, 只會顯示前兩個階層式層級。The SiteMapNodeCollection is a subset of the current site map, showing only the first two hierarchical levels.


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

備註

類別提供SiteMapNode物件的強型別集合。 SiteMapNodeCollectionThe SiteMapNodeCollection class provides a strongly typed collection for SiteMapNode objects. 它會SiteMapNode在內部將物件儲存在以零為基底的陣列中。It stores SiteMapNode objects internally in a zero-based array.

您可以在第SiteMapNodeCollection一次建立集合時進行修改, 然後使用下列方法來新增、複製和移除SiteMapNode物件:You can modify a SiteMapNodeCollection collection when it is first created, and then use the following methods to add, copy, and remove SiteMapNode objects:

您可以使用靜態SiteMapNodeCollection ReadOnly方法建立唯讀, 這不允許新增、複製和移除SiteMapNode物件。You can create a read-only SiteMapNodeCollection, which does not permit adding, copying, nor removing SiteMapNode objects, by using the static ReadOnly method. SiteMapNode.GetAllNodesSiteMapNodeCollection SiteMapNode ChildNodes SiteMapNodeCollection方法所傳回的集合是唯讀的, 這是在從傳回的物件上存取屬性時所傳回的。 GetChildren那裡.The SiteMapNodeCollection collections that are returned by the SiteMapNode.GetAllNodes and GetChildren methods are read-only, as is the SiteMapNodeCollection that is returned when the ChildNodes property is accessed on a SiteMapNode object that is returned from a provider. 如果您嘗試藉SiteMapNodeCollection由設定預設索引子屬性, 或使用下列任一方法來修改唯讀, 則會擲回例外狀況:NotSupportedExceptionA NotSupportedException exception is thrown, if you attempt to modify a read-only SiteMapNodeCollection by setting the default indexer property or by using any of the following methods:

呼叫上述清單中的任何方法之前, 請先使用屬性來檢查集合。IsReadOnlyUse the IsReadOnly property to check the collection before calling any of the methods in the preceding list.

建構函式

SiteMapNodeCollection() SiteMapNodeCollection() SiteMapNodeCollection() SiteMapNodeCollection()

初始化 SiteMapNodeCollection 類別的新執行個體,這個執行個體是預設的。Initializes a new instance of the SiteMapNodeCollection class, which is the default instance.

SiteMapNodeCollection(Int32) SiteMapNodeCollection(Int32) SiteMapNodeCollection(Int32) SiteMapNodeCollection(Int32)

使用指定的初始容量,初始化 SiteMapNodeCollection 類別的新執行個體。Initializes a new instance of the SiteMapNodeCollection class with the specified initial capacity.

SiteMapNodeCollection(SiteMapNode) SiteMapNodeCollection(SiteMapNode) SiteMapNodeCollection(SiteMapNode) SiteMapNodeCollection(SiteMapNode)

初始化 SiteMapNodeCollection 類別的新執行個體,並將 SiteMapNode 物件加入至集合的 InnerList 屬性。Initializes a new instance of the SiteMapNodeCollection class and adds the SiteMapNode object to the InnerList property for the collection.

SiteMapNodeCollection(SiteMapNodeCollection) SiteMapNodeCollection(SiteMapNodeCollection) SiteMapNodeCollection(SiteMapNodeCollection) SiteMapNodeCollection(SiteMapNodeCollection)

初始化 SiteMapNodeCollection 類別的新執行個體,並將指定之 SiteMapNodeCollection 集合的所有清單項目加入至集合的 InnerList 屬性。Initializes a new instance of the SiteMapNodeCollection class and adds all the list items of the specified SiteMapNodeCollection collection to the InnerList property for the collection.

SiteMapNodeCollection(SiteMapNode[]) SiteMapNodeCollection(SiteMapNode[]) SiteMapNodeCollection(SiteMapNode[]) SiteMapNodeCollection(SiteMapNode[])

初始化 SiteMapNodeCollection 類別的新執行個體,並將 SiteMapNode 型別陣列加入至集合的 InnerList 屬性。Initializes a new instance of the SiteMapNodeCollection class and adds the array of type SiteMapNode to the InnerList property for the collection.

屬性

Count Count Count Count

取得集合所包含的項目數目。Gets the number of elements contained in the collection.

IsFixedSize IsFixedSize IsFixedSize IsFixedSize

取得布林值,指出節點是否可以加入至集合或從集合減去。Gets a Boolean value indicating whether nodes can be added to or subtracted from the collection.

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

取得布林值,指出集合是否為唯讀。Gets a Boolean value indicating whether the collection is read-only.

IsSynchronized IsSynchronized IsSynchronized IsSynchronized

取得布林值,指出對集合的存取是否為同步的 (安全執行緒 (Thread-Safe))。Gets a Boolean value indicating whether access to the collection is synchronized (thread safe).

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

取得或設定位於集合中所指定索引處的 SiteMapNode 物件。Gets or sets the SiteMapNode object at the specified index in the collection.

SyncRoot SyncRoot SyncRoot SyncRoot

取得物件,這個物件可以用來對集合進行同步存取。Gets an object that can be used to synchronize access to the collection.

方法

Add(SiteMapNode) Add(SiteMapNode) Add(SiteMapNode) Add(SiteMapNode)

將單一 SiteMapNode 物件加入集合中。Adds a single SiteMapNode object to the collection.

AddRange(SiteMapNodeCollection) AddRange(SiteMapNodeCollection) AddRange(SiteMapNodeCollection) AddRange(SiteMapNodeCollection)

將指定之 SiteMapNodeCollection 中的節點加入至目前集合。Adds the nodes in the specified SiteMapNodeCollection to the current collection.

AddRange(SiteMapNode[]) AddRange(SiteMapNode[]) AddRange(SiteMapNode[]) AddRange(SiteMapNode[])

SiteMapNode 型別陣列加入至集合。Adds an array of type SiteMapNode to the collection.

Clear() Clear() Clear() Clear()

移除集合的所有項目。Removes all items from the collection.

Contains(SiteMapNode) Contains(SiteMapNode) Contains(SiteMapNode) Contains(SiteMapNode)

判斷集合是否含有指定的 SiteMapNode 物件。Determines whether the collection contains a specific SiteMapNode object.

CopyTo(SiteMapNode[], Int32) CopyTo(SiteMapNode[], Int32) CopyTo(SiteMapNode[], Int32) CopyTo(SiteMapNode[], Int32)

從目標陣列的指定索引處開始,將整個集合複製到相容的一維陣列。Copies the entire collection to a compatible one-dimensional array, starting at the specified index of the target array.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetDataSourceView(SiteMapDataSource, String) GetDataSourceView(SiteMapDataSource, String) GetDataSourceView(SiteMapDataSource, String) GetDataSourceView(SiteMapDataSource, String)

擷取與目前集合中之節點關聯的 SiteMapDataSourceView 物件。Retrieves the SiteMapDataSourceView object that is associated with the nodes in the current collection.

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

擷取對列舉值物件的參考,這個物件是用來逐一查看集合。Retrieves a reference to an enumerator object, which is used to iterate over the collection.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetHierarchicalDataSourceView() GetHierarchicalDataSourceView() GetHierarchicalDataSourceView() GetHierarchicalDataSourceView()

擷取與目前集合中之節點關聯的 SiteMapHierarchicalDataSourceView 物件。Retrieves the SiteMapHierarchicalDataSourceView object that is associated with the nodes in the current collection.

GetHierarchyData(Object) GetHierarchyData(Object) GetHierarchyData(Object) GetHierarchyData(Object)

傳回指定列舉項目的階層式資料項目。Returns a hierarchical data item for the specified enumerated item.

GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
IndexOf(SiteMapNode) IndexOf(SiteMapNode) IndexOf(SiteMapNode) IndexOf(SiteMapNode)

搜尋指定的 SiteMapNode 物件,然後傳回在整個集合中第一個符合元素之以零起始的索引。Searches for the specified SiteMapNode object, and then returns the zero-based index of the first occurrence within the entire collection.

Insert(Int32, SiteMapNode) Insert(Int32, SiteMapNode) Insert(Int32, SiteMapNode) Insert(Int32, SiteMapNode)

將指定的 SiteMapNode 物件插入至集合中所指定索引處。Inserts the specified SiteMapNode object into the collection at the specified index.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
OnValidate(Object) OnValidate(Object) OnValidate(Object) OnValidate(Object)

當驗證數值時,執行額外的自訂處理序。Performs additional custom processes when validating a value.

ReadOnly(SiteMapNodeCollection) ReadOnly(SiteMapNodeCollection) ReadOnly(SiteMapNodeCollection) ReadOnly(SiteMapNodeCollection)

傳回唯讀集合,其中包含指定之 SiteMapNodeCollection 集合中的節點。Returns a read-only collection that contains the nodes in the specified SiteMapNodeCollection collection.

Remove(SiteMapNode) Remove(SiteMapNode) Remove(SiteMapNode) Remove(SiteMapNode)

從集合中移除指定的 SiteMapNode 物件。Removes the specified SiteMapNode object from the collection.

RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)

從集合指定之索引處移除 SiteMapNode 物件。Removes the SiteMapNode object at the specified index of the collection.

ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

明確介面實作

ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32)

從特定的陣列索引處開始,將 ICollection 介面的項目複製到陣列。Copies the elements of the ICollection interface to an array, starting at a particular array index. 這個類別無法被繼承。This class cannot be inherited.

ICollection.Count ICollection.Count ICollection.Count ICollection.Count

取得 ICollection 介面中所包含的項目數。Gets the number of elements that are contained in the ICollection interface. 這個類別無法被繼承。This class cannot be inherited.

ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized

取得 Boolean 值,指出對 ICollection 介面的存取是否為同步 (安全執行緒)。Gets a Boolean value indicating whether access to the ICollection interface is synchronized (thread safe). 這個類別無法被繼承。This class cannot be inherited.

ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot

取得物件,可用來對 ICollection 介面進行同步存取。Gets an object that can be used to synchronize access to the ICollection interface. 這個類別無法被繼承。This class cannot be inherited.

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

傳回逐一查看集合的列舉值。Returns an enumerator that iterates through a collection. 如需這個成員的說明,請參閱 GetEnumerator()For a description of this member, see GetEnumerator().

IHierarchicalEnumerable.GetHierarchyData(Object) IHierarchicalEnumerable.GetHierarchyData(Object) IHierarchicalEnumerable.GetHierarchyData(Object) IHierarchicalEnumerable.GetHierarchyData(Object)

傳回指定列舉項目的階層式資料項目。Returns a hierarchical data item for the specified enumerated item. 如需這個成員的說明,請參閱 GetHierarchyData(Object)For a description of this member, see GetHierarchyData(Object).

IList.Add(Object) IList.Add(Object) IList.Add(Object) IList.Add(Object)

將項目加入至 IList 介面中的集合。Adds an item to the collection in the IList interface. 如需這個成員的說明,請參閱 Add(Object)For a description of this member, see Add(Object).

IList.Clear() IList.Clear() IList.Clear() IList.Clear()

將所有項目從 IList 介面中的集合移除。Removes all items from the collection in the IList interface. 如需這個成員的說明,請參閱 Clear()For a description of this member, see Clear().

IList.Contains(Object) IList.Contains(Object) IList.Contains(Object) IList.Contains(Object)

判斷 IList 介面中的集合是否包含指定的布林值。Determines whether the collection in the IList interface contains the specified Boolean value.

IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object)

判斷 IList 介面所傳回之集合中特定項目的索引。Determines the index of the specific item in the collection that is returned by the IList interface. 如需這個成員的說明,請參閱 IndexOf(Object)For a description of this member, see IndexOf(Object).

IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object)

將項目插入至 IList 介面的集合中指定之索引處。Inserts an item into the collection in the IList interface at the specified index. 如需這個成員的說明,請參閱 Insert(Int32, Object)For a description of this member, see Insert(Int32, Object).

IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize

取得 Boolean 值,指出集合是否具有固定大小。Gets a Boolean value indicating whether the collection has a fixed size. 如需這個成員的說明,請參閱 IsFixedSizeFor a description of this member, see IsFixedSize.

IList.IsReadOnly IList.IsReadOnly IList.IsReadOnly IList.IsReadOnly

取得 Boolean 值,指出集合是否為唯讀。Gets a Boolean value indicating whether the collection is read-only. 如需這個成員的說明,請參閱 IsReadOnlyFor a description of this member, see IsReadOnly.

IList.Item[Int32] IList.Item[Int32] IList.Item[Int32] IList.Item[Int32]

取得在指定索引處的 IList 項目。Gets the IList element at the specified index.

IList.Remove(Object) IList.Remove(Object) IList.Remove(Object) IList.Remove(Object)

IList 介面的集合中移除特定物件的第一個符合項目。Removes the first occurrence of a specified object from the collection in the IList interface. 如需這個成員的說明,請參閱 Remove(Object)For a description of this member, see Remove(Object).

IList.RemoveAt(Int32) IList.RemoveAt(Int32) IList.RemoveAt(Int32) IList.RemoveAt(Int32)

移除在指定索引處的 IList 項目。Removes the IList item at the specified index. 如需這個成員的說明,請參閱 RemoveAt(Int32)For a description of this member, see RemoveAt(Int32).

擴充方法

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryableConverts an IEnumerable to an IQueryable.

適用於

另請參閱