• 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;
            }
        }
  • 相关阅读:
    Android Studio开发JNIproject
    POJ 3006 Dirichlet&#39;s Theorem on Arithmetic Progressions 快筛质数
    ZooKeeper是什么?
    android学习记录(十三)Task 和 Activity 回退栈操作。
    Java程序员的日常—— IOUtils总结
    sql基础知识:分页+排序
    Elasticsearch推荐插件篇(head,sense,marvel)
    sql基础知识:日期的常用用法
    [大数据之Spark]——Actions算子操作入门实例
    [大数据之Spark]——Transformations转换入门经典实例
  • 原文地址:https://www.cnblogs.com/dennys/p/3624774.html
Copyright © 2020-2023  润新知