zoukankan      html  css  js  c++  java
  • hashtable and dictionary

          

    using System;
    using System.Collections.Generic;

    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Collections;

    namespace WindowsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }

            private void button1_Click(object sender, EventArgs e)
            {
                listBox1.Items.Clear();
                listBox2.Items.Clear();
                //using System.Collections;
                Hashtable ht = new Hashtable();
                ht.Add("001",1);
                ht.Add("002",2);
                ht.Add("003",3);

                foreach (string str in ht.Keys)
                {
                    listBox2.Items.Add(ht[str]);
                }
                foreach(DictionaryEntry h in ht)
                {
                    listBox1.Items.Add(h.Key);
                }
               


            }

            private void button2_Click(object sender, EventArgs e)
            {
                listBox2.Items.Clear();
                listBox1.Items.Clear();
                //using System.Collections.Generic;
                Dictionary<string, double> dictionary = new Dictionary<string, double>();
                dictionary.Add("001", 1);
                dictionary.Add("002", 2);
                dictionary.Add("003", 3);
                foreach (string str in dictionary.Keys)
                {
                    listBox2.Items.Add(dictionary[str]);
                }
                foreach(KeyValuePair<string ,double> kvp in dictionary)
                {
                    listBox1.Items.Add(kvp.Key);
                }
            }
        }
    }

  • 相关阅读:
    SQL SERVER中一些常见性能问题的总结
    【BZOJ2554】Color 概率神题
    【BZOJ1818】[Cqoi2010]内部白点 扫描线+树状数组
    【BZOJ1879】[Sdoi2009]Bill的挑战 状压DP
    【BZOJ2668】[cqoi2012]交换棋子 费用流
    【BZOJ4372】烁烁的游戏 动态树分治+线段树
    【BZOJ3470】Freda’s Walk 概率与期望
    【BZOJ2087】[Poi2010]Sheep 几何+DP
    【BZOJ4428】[Nwerc2015]Debugging调试 记忆化搜索+分块
    【BZOJ2137】submultiple 高斯消元求伯努利数
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/1490676.html
Copyright © 2011-2022 走看看