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(); 
                }
            }

  • 相关阅读:
    绝对干货:供个人开发者赚钱免费使用的一些好的API接口
    科普技术贴:个人开发者的那些赚钱方式
    北漂程序员的笑与泪
    非著名程序员公众号
    北漂程序员的笑与泪
    【有人@我】Android中高亮变色显示文本中的关键字
    新时代的coder如何成为专业程序员
    自定义圆形控件RoundImageView并认识一下attr.xml
    偷天换日:网络劫持,网页js被伪装替换。
    jeesite 去掉 /a
  • 原文地址:https://www.cnblogs.com/scottckt/p/854426.html
Copyright © 2011-2022 走看看