日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

学用 ASP.Net 之 System.Collections.Specialized.CollectionsUtil 类

發布時間:2025/3/20 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 学用 ASP.Net 之 System.Collections.Specialized.CollectionsUtil 类 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

通過 CollectionsUtil 創建或包裝的 "鍵/值對" 類(實現 IDictionary 的), 可以忽略 Key 的大小寫.

主要成員:
/* 靜態方法 */ CollectionsUtil.CreateCaseInsensitiveHashtable(); //建立或包裝 Hashtable 等, 可初始化容量 CollectionsUtil.CreateCaseInsensitiveSortedList(); //建立有序的哈希表 SortedList

創建忽略大小寫的 Hashtable:
protected void Button1_Click(object sender, EventArgs e) {Hashtable hash = CollectionsUtil.CreateCaseInsensitiveHashtable(); //這就建立了一個忽略大小寫的哈希表hash["KEY1"] = 123;int n = (int)hash["key1"]; //123TextBox1.Text = n.ToString();try { hash.Add("Key1", 456); }catch (Exception err) { Response.Write(err.Message); } //已添加項。字典中的關鍵字:“KEY1”所添加的關鍵字:“Key1” }

創建忽略大小寫的 SortedList:
protected void Button1_Click(object sender, EventArgs e) {SortedList sl = CollectionsUtil.CreateCaseInsensitiveSortedList(); //這就建立了一個忽略大小寫的 SortedListsl["KEY1"] = 123;TextBox1.Text = sl["key1"].ToString(); //123try { sl.Add("Key1", 456); }catch (Exception err) { Response.Write(err.Message); } //已添加項。字典中的關鍵字:“KEY1”所添加的關鍵字:“Key1” }

包裝一個 Hashtable 為忽略大小寫:
protected void Button1_Click(object sender, EventArgs e) {Hashtable hash = new Hashtable();hash.Add("KEY1", "aaa");hash.Add("KEY2", "bbb");hash.Add("KEY3", "ccc");bool b1 = hash.Contains("KEY1"); //Truebool b2 = hash.Contains("key1"); //Falsehash = CollectionsUtil.CreateCaseInsensitiveHashtable(hash);bool b3 = hash.Contains("key1"); //TrueTextBox1.Text = string.Concat(b1, "\n", b2, "\n", b3); }

總結

以上是生活随笔為你收集整理的学用 ASP.Net 之 System.Collections.Specialized.CollectionsUtil 类的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。