Mega Code Archive

 
Categories / Visual C++ .NET / Collections
 

Using for loop the display elements in an ArrayList

#include "stdafx.h" using namespace System; using namespace System::Collections; void main() {     ArrayList ^alist = gcnew ArrayList(4); // will double to 8     alist->Add("One");     alist->Add("-");     array<String^>^ morenums = gcnew array<String^> {"Four", "Five"};     alist->AddRange(morenums);     for (int i = 0; i < alist->Count; i++)     {         Console::Write("{0} ", alist[i]);     } }