CreateCaseInsensitiveHashtable() | 创建 Hashtable 类具有默认初始容量的不区分大小写的新实例。 | |
![]() ![]() | CreateCaseInsensitiveHashtable(IDictionary) | 将项从指定字典复制到 Hashtable 类的不区分大小写的新实例,该实例具有与复制项的数量相同的初始容量。 |
![]() ![]() | CreateCaseInsensitiveHashtable(Int32) | 创建 Hashtable 类具有指定初始容量的不区分大小写的新实例。 |
![]() ![]() | CreateCaseInsensitiveSortedList | 创建 SortedList 类的新实例,该实例忽略字符串的大小写。 |
![]() | Equals(Object) | 确定指定的对象是否等于当前对象。 (继承自 Object。) |
![]() | Finalize | 允许对象在“垃圾回收”回收之前尝试释放资源并执行其他清理操作。 (继承自 Object。) |
![]() | GetHashCode | 用作特定类型的哈希函数。 (继承自 Object。) |
![]() | GetType | 获取当前实例的 Type。 (继承自 Object。) |
![]() | MemberwiseClone | 创建当前 Object 的浅表副本。 (继承自 Object。) |
![]() | ToString | 返回表示当前对象的字符串。 (继承自 Object。) |
using System;
using System.Collections;
using System.Collections.Specialized;
class TestCollectionsUtils
{
public static void Main()
{
Hashtable population1 = CollectionsUtil.CreateCaseInsensitiveHashtable();
population1["Trapperville"] = 15;
population1["Doggerton"] = 230;
population1["New Hollow"] = 1234;
population1["McHenry"] = 185;
// Select cities from the table using mixed case.
Console.WriteLine("Case insensitive hashtable results:\n");
Console.WriteLine("{0}'s population is: {1}", "Trapperville", population1["trapperville"]);
Console.WriteLine("{0}'s population is: {1}", "Doggerton", population1["DOGGERTON"]);
Console.WriteLine("{0}'s population is: {1}", "New Hollow", population1["New hoLLow"]);
Console.WriteLine("{0}'s population is: {1}", "McHenry", population1["MchenrY"]);
SortedList population2 = CollectionsUtil.CreateCaseInsensitiveSortedList();
foreach (string city in population1.Keys)
{
population2.Add(city, population1[city]);
}
// Select cities from the sorted list using mixed case.
Console.WriteLine("\nCase insensitive sorted list results:\n");
Console.WriteLine("{0}'s population is: {1}", "Trapperville", population2["trapPeRVille"]);
Console.WriteLine("{0}'s population is: {1}", "Doggerton", population2["dOGGeRtON"]);
Console.WriteLine("{0}'s population is: {1}", "New Hollow", population2["nEW hOLLOW"]);
Console.WriteLine("{0}'s population is: {1}", "McHenry", population2["MchEnrY"]);
}
}