System.Web.UI.WebControls.TreeNodeCollection.GetEnumerator Method

Returns an enumerator that can be used to iterate through a System.Web.UI.WebControls.TreeNodeCollection object.

Syntax

public IEnumerator GetEnumerator ()

Returns

An enumerator that can be used to iterate through the System.Web.UI.WebControls.TreeNodeCollection.

Remarks

Use the TreeNodeCollection.GetEnumerator method to create an enumerator that can be easily iterated through to get each item in the System.Web.UI.WebControls.TreeNodeCollection. To get the item currently pointed to in the enumerator, use the IEnumerator.Current property. Use the IEnumerator.MoveNext method to move to the next item. If you need to move the enumerator back to the beginning of the collection, use the IEnumerator.Reset method.

Note:

After you create an enumerator or use the IEnumerator.Reset method, you must call the IEnumerator.MoveNext method. Otherwise, the item represented by the IEnumerator.Current property is undefined.

As an alternative, you can also use the TreeNodeCollection.CopyTo(TreeNode[], int) method to create an Array object that can be used to access the items in the collection. Another alternative is to use a foreach or For Each structure to iterate through the collection.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0