zoukankan      html  css  js  c++  java
  • 集合的遍历


    1、ArrayList的遍历

      foreach ( Object obj in myList )
      {
       Console.Write( "   {0}", obj );
      }
    

    2、Hashtable的遍历

     for(DictionaryEntry   de   in   ht)   //ht为一个Hashtable实例 
      { 
          Console.WriteLine(de.Key);//de.Key对应于key/value键值对key 
          Console.WriteLine(de.Value);//de.Key对应于key/value键值对value 
      }
    

    3、List<T>的遍历

      List<String>  myList=new List<String>()
      foreach(String item in myList)
      {
       console.writelist(item);
      }
    

    4、Dictionary<T,V>的遍历

      Dictionary<string,string> openWith=new Dictionary<string,string>();
    
      foreach( KeyValuePair<string, string> kvp in openWith )
            {
                Console.WriteLine("Key = {0}, Value = {1}", 
                    kvp.Key, kvp.Value);
            }
    
      Dictionary<string, string>.ValueCollection valueColl = openWith.Values;
    
            foreach( string s in valueColl )
            {
                Console.WriteLine("Value = {0}", s);
            }
    
  • 相关阅读:
    查看占用内存cpu top10
    free 详解
    find
    服务器硬件查看
    firewalld命令使用
    firewalld-zone概念介绍
    Jenkins rpm包安装
    攻击防御案例
    filebeat收集系统登陆日志
    nginx转换json格式
  • 原文地址:https://www.cnblogs.com/dedeyi/p/2580972.html
Copyright © 2011-2022 走看看