• dictionary List


    class Program
        {
            static void Main(string[] args)
            {
                Hashtable hs=new Hashtable();
                List<Game> collection=new List<Game>(120);
                Game[] fs=
                    {
                        new Game(1,"100","alisdun"), 
                        new Game(2,"200","blisdun"), 
                        new Game(3,"300","clisdun"), 
                        new Game(4,"400","dlisdun"), 
                        new Game(5,"500","elisdun"), 
                        new Game(6,"600","flisdun"), 
                        new Game(7,"700","glisdun"), 
                        new Game(8,"800","hlisdun"), 
                        new Game(9,"900","ilisdun"), 
                        new Game(10,"1100","jlisdun"), 
                        new Game(11,"1200","klisdun") 
                    };
                foreach (var game in fs)
                {
                    hs.Add(game.Gid,game);
    
                    collection.Add(game);
                }
    
                Console.WriteLine("打印原始Hashtable中。。。。。");
                foreach (DictionaryEntry game in hs)
                {
                    Console.WriteLine(((Game)game.Value).Gid + " ; " + ((Game)game.Value).Record + " ; " + ((Game)game.Value).Alliance);
                }
                Console.WriteLine();
    
                Console.WriteLine("移除hashtable键11,修改键10的值。。。。。");
    
                hs.Remove(11);
                ((Game)hs[10]).Record = "denny";
               ((Game)hs[10]).Alliance= "ahah";;
    
                Console.WriteLine("打印collection中。。。。。");
                foreach (var game in collection)
                {
                    Console.WriteLine(game.Gid+" ; "+game.Record+" ; "+game.Alliance);
                }
    
                Console.WriteLine();
                Console.WriteLine("打印修改后Hashtable中。。。。。");
                foreach (DictionaryEntry game in hs)
                {
                    Console.WriteLine(((Game)game.Value).Gid + " ; " + ((Game)game.Value).Record+" ; "+((Game)game.Value).Alliance);
                }
                Console.WriteLine();
    
                Console.WriteLine("修改collection。。。。。");
                collection[0].Record = "duck";
                Console.WriteLine("打印修改collection后Hashtable中。。。。。");
                foreach (DictionaryEntry game in hs)
                {
                    Console.WriteLine(((Game)game.Value).Gid + " ; " + ((Game)game.Value).Record + " ; " + ((Game)game.Value).Alliance);
                }
                Console.ReadKey();
            }
        }
    
        class Game
        {
            public int Gid;
            public string Record;
            public string Alliance;
            public Game(int gid,string record,string alliance)
            {
                Gid = gid;
                Record = record;
                Alliance = alliance;
            }
        }
  • 相关阅读:
    改善用户体验之alert提示效果
    用javascript制作放大镜放大图片
    window.history.go(1)返回上页的同时刷新"上页"技术
    JS折叠菜单
    懒得勤快的博客 resharper 等好文
    IBM DOMINO LOTUS LIMITS
    为CKEditor开发FLV视频播放插件
    Calling DLL routines from LotusScript. Part I: Windows API
    lotus domino下使用FCKeditor
    domino文件拆离数据库,放入指定目录
  • 原文地址:https://www.cnblogs.com/dennys/p/3624774.html
Copyright © 2020-2023  润新知