#include "stdafx.h" using namespace System; using namespace System::Collections; /* Exemple de Tableau Associatif. MesExemples.com */ Int32 main(void) { try { // Créer un objet Hashtable Hashtable ^hash = gcnew Hashtable(); // Créer tableaux de clé et valeurs array<String ^> ^keys = gcnew array<System::String ^>{ "fr", "en", "gr", "de" }; // Représentent les codes de pays array<String ^> ^values = gcnew array<String ^>{ "français", "anglais", "grec", "allemand" };// Représentent les pays // Combiner les deux tableaux dans un tableau associatif HashTable for (Int32 i = 0; i < keys->Length; i++) { hash->Add(keys[i], values[i]); } // Afficher le contenu de Hashtable par sa clé Console::WriteLine(hash->default["gr"]); // trouver l'entrée avec la clé 'gr'="grec" Console::WriteLine(hash->default["de"]); // trouver l'entrée avec la clé 'de'="allemand" } catch (Exception ^e) { Console::WriteLine(e->StackTrace); } Console::ReadLine(); return 0; }