zoukankan      html  css  js  c++  java
  • 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;
            }
        }
  • 相关阅读:
    详解Paint的setPathEffect(PathEffect effect)
    详解Paint的setMaskFilter(MaskFilter maskfilter)
    用TextPaint来绘制文字
    详解Paint的setXfermode(Xfermode xfermode)
    详解Paint的setColorFilter(ColorFilter filter)
    ASP.NET Core 高性能开发最佳实践
    疫苗,为啥还要等这么久?
    物联网行业的基本系统架构
    超级强大的学习方法--费曼技巧
    衡水中学学霸李江珊,高考英语149分,从不刷题的她如何做到的
  • 原文地址:https://www.cnblogs.com/dennys/p/3624774.html
Copyright © 2011-2022 走看看