Learning to use the system. Collections. Specialized. stringdictionary class of ASP. NET

Source: Internet
Author: User
Stringdictionary is equivalent to a hash table where both the key and value are strings.
Main members:
 
/* Attribute */count; // keys; // key set values; // value set/* Method */Add (); // clear (); // containskey (); // whether it contains the specified key containsvalue (); // whether it contains the specified value copyto (); // assign the specified value to the array remove (); // Delete by key
Simple exercises:
Protected void button1_click (Object sender, eventargs e) {stringdictionary SD = new stringdictionary (); SD. add ("K1", "AAA"); SD. add ("K2", "BBB"); SD. add ("K3", "CCC"); SD ["K2"] = "BBB"; string STR = ""; foreach (dictionaryentry de in SD) // system. collections. dictionaryentry {STR + = string. format ("{0 }:{ 1};", de. key, de. value);} textbox1.text = STR; // K1: AAA; K2: BBB; K3: CCC;} protected void button2_click (Object sender, eventargs E) {stringdictionary SD = new stringdictionary (); SD. add ("K1", "AAA"); SD. add ("K2", "BBB"); SD. add ("K3", "CCC"); string str1, str2; str1 = str2 = ""; foreach (string s in SD. keys) {str1 + = S + ",";} // K1, K2, K3, foreach (string s in SD. values) {str2 + = S + "," ;}// AAA, BBB, CCC, textbox1.text = str1 + "\ n" + str2 ;}

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.