RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
IEnumerable Interface

IEnumerable is the generic interface for enumerable containers.

Pascal
IEnumerable<T> = interface(IEnumerable);
C++
template <T>
__interface IEnumerable : public IEnumerable;

To make your container enumerable, implement the IEnumerable interface. IEnumerable exposes a single method called GetEnumerator, that must return a reference to an IEnumerator interface.  

Classes that implement the IEnumerable interface are considered enumerable in Delphi language and can be used in for..in statements.

Note: It is not required that IEnumerable be actually implemented by a class in order to be considered enumerable. It is enough to export a public method called GetEnumerator that returns an enumerator object. Still, we recommend that you implement the IEnumerable interface.
 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!