Introduction:
This article explains about hashtable. Hashtable optimizes lookups. It computes a hash of each key you add. It then uses this hash code to look up the element very quickly. It is an older .NET Framework type. It is slower than the generic Dictionary type.Example:
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); } } }
Output:
13, Thirteen
2, Two
1, One
2, Two
1, One
No comments:
Post a Comment