using System; using System.Collections; namespace Hashtable { public class KeyValue { string k,v; public KeyValue( string Key, string Value ) { k = Key; v = Value; } public string Key { get { return k; } } public string Value { get { return v; } } } class MainClass { /// /// Der Haupteinstiegspunkt für die Anwendung. /// [STAThread] static void Main(string[] args) { System.Collections.Hashtable h = new System.Collections.Hashtable(); string [] keys = { "lcu.long_name_one", "lcu.long_name_two", "lcu.long_three" }; h.Add( keys[0], new KeyValue( keys[0], "Value Of 1" ) ); h.Add( keys[1], new KeyValue( keys[1], "Value Of 2" ) ); h.Add( keys[2], new KeyValue( keys[2], "Value Of 3" ) ); int iCount = 0; while( h.Count > 0 ) { Console.WriteLine( "Count = " + h.Count ); IEnumerator e = h.Values.GetEnumerator(); if( e.MoveNext() ) { Console.WriteLine( "Killing Value " + ((KeyValue)e.Current).Key ); h.Remove( ((KeyValue)e.Current).Key ); } if( ++iCount > 10 ) { Console.WriteLine( "\nUUUUUUUU theres a bug in hashtable!!!" ); Console.WriteLine( "now the table should be empty!!!" ); break; } } } } }