C # Foundation fourth day-job answer-hashtable-list<keyvaluepair> generic implementation business card

Source: Internet
Author: User

1. Hashtable Implement Hashtable Table=NewHashtable ();  while(true) {Console.WriteLine ("------------------1. Increase--------------------"); Console.WriteLine ("------------------2. Query--------------------"); Console.WriteLine ("------------------3. Check all----------------"); Console.WriteLine ("------------------4. Delete--------------------"); Console.WriteLine ("Please enter the features you want to use:"); intnum =int.                Parse (Console.ReadLine ()); Switch(num) { Case 1: Console.WriteLine ("Please enter your name:"); stringName =Console.ReadLine (); Console.WriteLine ("Please enter the age gender Hobby contact Method:"); stringstr =Console.ReadLine (); Table.                        ADD (name, str);  Break;  Case 2: Console.WriteLine ("Please enter your name:"); stringNamequery =Console.ReadLine ();                        Console.WriteLine (); if(table. Contains (Namequery)) {Console.WriteLine (Namequery+" "+Table[namequery]); }                         Break;  Case 3: Console.WriteLine (); foreach(DictionaryEntry Dinchtable) {Console.WriteLine (D.key+" "+d.value); }                         Break;  Case 4: Console.WriteLine ("Please enter your name:"); stringDelete =Console.ReadLine (); Table.                        Remove (delete);  Break; }2:list<keyvaluepair>Generic Implementation List<KeyValuePair<string,string>> Listkey =Newlist<keyvaluepair<string,string>>();  while(true) {Console.WriteLine ("------------------1. Increase--------------------"); Console.WriteLine ("------------------2. Query--------------------"); Console.WriteLine ("------------------3. Check all----------------"); Console.WriteLine ("------------------4. Delete--------------------"); Console.WriteLine ("Please enter the features you want to use:"); intnum =int.                Parse (Console.ReadLine ()); Switch(num) { Case 1: Console.WriteLine ("Please enter the name you added:"); stringName =Console.ReadLine (); Console.WriteLine ("Please enter the age gender Hobby contact Method:"); stringstr =Console.ReadLine (); Listkey. ADD (Newkeyvaluepair<string,string>(name, str)); Console.WriteLine ("Success");  Break;  Case 2: Console.WriteLine ("Please enter the name of the search:"); stringNamequery =Console.ReadLine ();                        Console.WriteLine (); if(Listkey) {Console.WriteLine (Namequery+" "+Listkey[namequery]); } Console.WriteLine ("Success");  Break;  Case 3: Console.WriteLine ("Find All"); foreach(DictionaryEntry DinchListkey) {Console.WriteLine (D.key+" "+d.value); } Console.WriteLine ("Success");  Break;  Case 4: Console.WriteLine ("Please enter the name of the deletion:"); stringDelete =Console.ReadLine (); Table.                        Remove (delete); Console.WriteLine ("Success");  Break; }

C # Foundation fourth day-job answer-hashtable-list<keyvaluepair> generic implementation business card

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.