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;
            }
        }
  • 相关阅读:
    (转载)林轩田机器学习基石课程学习笔记1 — The Learning Problem
    二、HDFS(架构、读写、NN)
    剑指:和为S的两个数字
    剑指:和为S的连续正数序列
    Hive:数据倾斜
    linux如何查看端口被哪个进程占用
    du查看某个文件或目录占用磁盘空间的大小
    剑指:滑动窗口的最大值
    leetcode之求众数
    剑指:重建二叉树
  • 原文地址:https://www.cnblogs.com/dennys/p/3624774.html
Copyright © 2011-2022 走看看