Mega Code Archive

 
Categories / Visual C++ .NET / Collections
 

Loop through a StringDictionary with for loop

#include "stdafx.h" #using <system.dll> using namespace System; using namespace System::Collections; using namespace System::Collections::Specialized; void main() {     StringDictionary ^strdict = gcnew StringDictionary();     strdict->Add("D", "d");     strdict->Add("F", "f");     strdict["C"] = "c";          ArrayList ^alist = gcnew ArrayList();     alist->AddRange(strdict->Keys);     alist->Sort();          for (int i = 0; i < alist->Count; i++)     {         Console::WriteLine("{0,10}:\t{1}", alist[i],              strdict[(String^)alist[i]]);     } }