學用 ASP.Net 之 System.Collections.Specialized.StringDictionary 類

來源:互聯網
上載者:User
StringDictionary 相當於 Key 和 Value 都是字串的雜湊表.
主要成員:
/* 屬性 */Count;  //Keys;   //鍵集合Values; //值集合/* 方法 */Add();           //Clear();         //ContainsKey();   //是否包含指定鍵ContainsValue(); //是否包含指定值CopyTo();        //將指定值賦值到數組Remove();        //根據鍵刪除
簡單練習:
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;}
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.