zoukankan      html  css  js  c++  java
  • 學習使用Directionary與Hastable

    最近測試開發的系統時,發現網絡連接速度很慢,但經過同事的不懈努力,系統在速度有了很大提升,其中一個改善方法就是將HashTable改為Directionary。兩者在用法基本相司,今天我特意學習了一下:
            /// <summary>
            
    /// 學習Directionary
            
    /// </summary>
            private void stuDirectionary()
            {
                
    //定議一下Dictionary類型
                Dictionary<intstring> dDirectionary = new Dictionary<intstring>();
                dDirectionary.Add(
    0"0000");
                dDirectionary.Add(
    1"1111");

                
    //獲取key值方法1
                foreach (int var in dDirectionary.Keys)
                {
                    
    int i = var;
                }

                
    //獲取key值方法2:用Keys集合轉移到ArrayList,用ArrayList轉出
                ArrayList al = new ArrayList(dDirectionary.Keys);
                
    for (int iArray = 0; iArray < al.Count; iArray++)
                {
                    
    //將獲得每個Value值賦給sDirectionaryValue
                    string sDirectionaryValue = al[iArray].ToString();
                }

                
    //循環得到Dictionary中value的值
                for (int iDCount = 0; iDCount < dDirectionary.Count; iDCount++)
                {
                    
    //將獲得每個Value值賦給sDirectionaryValue
                    string sDirectionaryValue = dDirectionary[iDCount];
                }

            }

            
    /// <summary>
            
    /// 學習HashTable
            
    /// </summary>
            private void stuHashTable()
            {
                
    //定一個Hastable
                Hashtable htHastable = new Hashtable();
                
    //填加HastTable值
                htHastable.Add(0"0000");
                htHastable.Add(
    1"1111");

                
    //獲得HashTable中每個Value值1
                foreach (string var in htHastable.Values)
                {
                   
    //將獲得每個Value值賦給sHtValue
                    string sHtValue = var;
                }
                
    //獲得HashTable中每個Value值2
                for (int ihtCount = 0; ihtCount < htHastable.Count; ihtCount++)
                {
                    
    //將獲得每個Value值賦給sHtValue
                    string sHtValue = htHastable[ihtCount].ToString(); 
                }
            }

  • 相关阅读:
    给Apache增加SSI支持(shtml的奥秘)
    Raphael实现商品来源去向图
    有趣的居中方式
    oc-基本语法
    APMServ 配置记录
    解决Mac Chrome打开HTTPS证书错误问题
    JavaScript生成GUID的算法
    Backbone模型
    利用apply和arguments复用方法
    软件复用的几种方式
  • 原文地址:https://www.cnblogs.com/scottckt/p/854426.html
Copyright © 2011-2022 走看看