日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > asp.net >内容正文

asp.net

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

發布時間:2025/3/20 asp.net 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 学用 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 类的全部內容,希望文章能夠幫你解決所遇到的問題。

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