// ArrayList.cpp : main project file.

#include "stdafx.h"

using namespace System;
using namespace System::Collections;
void PrintValues(IEnumerable^ myList);

int main(array<System::String ^> ^args)
{
	// Creates and initializes a new ArrayList.
	Console::WriteLine("Creating and initializing a new ArrayList...");
	Console::WriteLine();
	ArrayList^ myAL = gcnew ArrayList;
	myAL->Add("Hello");
	myAL->Add("Dirty");
	myAL->Add("Programming");
	myAL->Add("World!");

	// Displays the properties and values of the .
	Console::WriteLine("myAL ArrayList:");
	Console::WriteLine(" Count:    {0}", myAL->Count);
	Console::WriteLine(" Capacity: {0}", myAL->Capacity);
	Console::Write(" Values:");
	PrintValues(myAL);
	return 0;
}

void PrintValues(IEnumerable^ myList)
{
	IEnumerator^ myEnum = myList->GetEnumerator();
	while (myEnum->MoveNext())
	{
		Object^ obj = safe_cast<Object^>(myEnum->Current);
		Console::Write("   {0}", obj);
	}
	Console::WriteLine();
}


