0 out of 1 rated this helpful - Rate this topic

IHierarchicalEnumerable Interface

Note: This interface is new in the .NET Framework version 2.0.

Represents a hierarchical collection that can be enumerated with an IEnumerator interface. Collections that implement the IHierarchicalEnumerable interface are used by ASP.NET site navigation and data source controls.

Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)

public interface IHierarchicalEnumerable : IEnumerable
public interface IHierarchicalEnumerable extends IEnumerable
public interface IHierarchicalEnumerable extends IEnumerable

The IHierarchicalEnumerable interface extends the IEnumerable interface and exposes GetHierarchyData, which is a method used to retrieve an IHierarchyData object from an enumerated item, in addition to the GetEnumerator method.

Typically, clients that use IHierarchicalEnumerable collections retrieve an IEnumerator object by calling the GetEnumerator method, then iterate through the enumeration and call the GetHierarchyData on each enumerated item to retrieve an IHierarchyData object.

The following code example demonstrates how to implement the IHierarchicalEnumerable interface with a class that extends ArrayList and provides a collection of IHierarchyData objects that wrap FileSystemInfo objects. The IHierarchicalEnumerable collection is used by classes that derive from HierarchicalDataSourceView to return a collection of hierarchical nodes when the Select method is called. This code example is part of a larger example provided for the HierarchicalDataSourceControl class.

// A collection of FileSystemHierarchyData objects
public class FileSystemHierarchicalEnumerable : ArrayList, IHierarchicalEnumerable
{
    public FileSystemHierarchicalEnumerable () : base (){
    }

    public IHierarchyData GetHierarchyData(object enumeratedItem) {
        return enumeratedItem as IHierarchyData;
    }
}


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ