Interface of enumerator which can be used to iterate through some elements. Objects of this class should only be allocated using System::MakeObject() function. Never create instance of this type on stack or using operator new, as it will result in runtime errors and/or assertion faults. Always wrap this class into System::SmartPtr pointer and use this pointer to pass it to functions as argument.
Moves enumerator to the next element. If no element was referenced before, sets reference to the first element available. If container end was hit, does nothing.
#include<system/collections/list.h>#include<system/smart_ptr.h>usingnamespaceSystem;usingnamespaceSystem::Collections::Generic;intmain(){// Create the List-class instance.
autocollection=MakeObject<List<int>>();// Fill the list.
collection->Add(1);collection->Add(2);collection->Add(3);// Get the enumerator of the list.
autoenumerator=collection->GetEnumerator();while(enumerator->MoveNext()){// Get the current element and print it.
std::cout<<enumerator->get_Current()<<' ';}// Reset the enumerator.
enumerator->Reset();return0;}/*
This code example produces the following output:
1 2 3
*/