Using IEnumerator to loop through an array : IEnumerator « Collections « Visual C++ .NET






Using IEnumerator to loop through an array

 

#include "stdafx.h"
using namespace System;
using namespace System::Collections;

int main()
{
   array<DateTime^>^ dateArray = gcnew array<DateTime^>(2);

   dateArray[0] = gcnew DateTime(1970, 12, 18);
   dateArray[1] = gcnew DateTime(1990, 1, 5);

   IEnumerator^ enumerator1 = dateArray->GetEnumerator();
   while ( enumerator1->MoveNext() )
   {
      DateTime^ current = (DateTime^) enumerator1->Current;
      Console::WriteLine( current->ToString("MM/dd/yyyy") );
   }

}

   
  








Related examples in the same category

1.Use while loop and Enumerator to loop through an array
2.Get key and value Enumerator
3.Display elements in a multiset by IEnumerator<> interface
4.Push pets onto stack and display by IEnumerator<> interface
5.vector for each loop using built in IEnumerator<> interface