Assembly: Collections;
IEnumerable - abstract interface of collections supporting element search.
IEnumerable
The interface does not contain its own properties and methods. Interface internal implementation enables the user to work with collections using the For Each operator.
NOTE. Inheritance from IEnumerable is not a mandatory condition to support For Each. For some collections existing in Fore their own support of the For Each operator is implemented.
Below is the example of the IEnumerable interface that is used to create a universal procedure to view any collections inherited from IEnumerable.
Sub UserProc;
Sub ShowCollection(Collection: IEnumerable);
Var
v: Variant;
Begin
For Each v In Collection Do
Debug.WriteLine(v);
End For;
End Sub ShowCollection;
Var
ArrList: IArrayList;
StrList: IStringList;
Begin
//Create and fill a dynamic array of any values
ArrList := New ArrayList.Create;
ArrList.Add("A");
ArrList.Add(Integer.MaxValue);
ArrList.Add(DateTime.MaxValue);
//Create and fill a dynamic array of strings
StrList := New StringList.Create;
StrList.Add("One");
StrList.Add("Two");
StrList.Add("Three");
//View collections
ShowCollection(ArrList);
ShowCollection(StrList);
End Sub UserProc;
See also: