CSharp:Hashtable
From Aino Wiki
Le hashtable possono esser paragonate ai Dictionary, sulla rete spesso si opta per quest'ultimi perferibili per prestazioni etc. I Dictionary internamente sono comunque rappresentati come hashtable.
Alcuni link per informazioni sul confronto:
Hash table in esempi
Sono vettori\dizionari ottimizzati. Da DotNet perls
Es. 1
using System; using System.Collections; class Program { static void Main() { Hashtable hashtable = new Hashtable(); hashtable[1] = "One"; hashtable[2] = "Two"; hashtable[13] = "Thirteen"; foreach (DictionaryEntry entry in hashtable) { Console.WriteLine("{0}, {1}", entry.Key, entry.Value); } } }
13, Thirteen 2, Two 1, One
Es. 2
using System; using System.Collections; class Program { static Hashtable GetHashtable() { // Create and return new Hashtable. Hashtable hashtable = new Hashtable(); hashtable.Add("Area", 1000); hashtable.Add("Perimeter", 55); hashtable.Add("Mortgage", 540); return hashtable; } static void Main() { Hashtable hashtable = GetHashtable(); // See if the Hashtable contains this key. Console.WriteLine(hashtable.ContainsKey("Perimeter")); // Test the Contains method. It works the same way. Console.WriteLine(hashtable.Contains("Area")); // Get value of Area with indexer. int value = (int)hashtable["Area"]; // Write the value of Area. Console.WriteLine(value); } }
True True 1000