C # Generic Dictionary (hashtable) using system; using system. collections. generic; public class example {public static void main () {// create a generic hash table and add the element dictionary <string, string> Oscar = new dictionary <string, string> (); Oscar. add ("Hali berry", "dance of death"); Oscar. add ("Judy danqi", "Join Hands"); Oscar. add ("nikol Kidman", "Moulin Rouge"); Oscar. add ("Jennifer Connery", "beautiful soul"); Oscar. add ("renni ziweige", "BJ singlediary"); // Delete the element Oscar. remove ("Jennifer Connery"); // assume If no element exists, add the element if (! Oscar. containskey ("Sisi · sparks") Oscar. add ("Sisi sepke", ""); // The volume and number of elements are displayed on the console. writeline ("number of elements: {0}", Oscar. count); // traverses the console of the set. writeline ("74 Oscar best actress and movie:"); foreach (keyvaluepair <string, string> kVp in Oscar) {console. writeline ("Name: {0}, movie: {1}", kVp. key, kVp. value);} // obtain the set of keys in the hash table <string, string>. keycollection keycoll = Oscar. keys; // The console that traverses the key set. writeline ("Best Actress:"); foreach (string s in keycoll) {console. writeline (s) ;}// set of hash table values <string, string>. valuecollection valuecoll = Oscar. values; // The set console that traverses values. writeline ("Best Actress movie:"); foreach (string s in valuecoll) {console. writeline (s);} // use the trygetvalue method to obtain the string slove = string corresponding to the specified key. empty; If (Oscar. trygetvalue ("Judy danqi", out slove) console. writeline ("My favorite movie {0} Judy danqi", slove); else console. writeline ("movie of Judy danqi not found"); // clear the hash table Oscar. clear (); console. readline: