zoukankan      html  css  js  c++  java
  • CollectionsUtil 类

    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: ");
            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(" Case insensitive sorted list results: ");
            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"]);
        }
    }

     

  • 相关阅读:
    第十一周上机作业
    第十三周作业 张垚
    第十三周上机 张垚
    十二周作业 张垚
    第十二周上机 张垚
    第十一周作业 张垚
    第十一周上机 张垚
    第十周 上机 张垚
    第九周上机 张垚
    第八周 下 张垚
  • 原文地址:https://www.cnblogs.com/fulai/p/3334331.html
Copyright © 2011-2022 走看看