爱问知识人 爱问教育 医院库

C#中Dictionary几种遍历的实现代码

首页

C#中Dictionary几种遍历的实现代码


        

提交回答
好评回答
  • 2023-03-06 06:30:00
      代码如下:
    Dictionary<string,string> list=new Dictionary<string,string>
    //3。0以上版本
    foreach(var item in list)
    {
    Console。
      WriteLine(item。Key+item。Value);
    }
    //KeyValuePair<T,K>
    foreach(KeyValuePair<string,string> kv in list)
    {
    Console。
      WriteLine(kv。Key+kv。Value);
    }
    //通过键的集合取
    foreach(string key in list。Keys)
    {
    Console。
      WriteLine(key+list[key]);
    }
    //for循环遍历
    List<string> test=new List<string>(list。Keys);
    for(int i=0;i<list。
      Count;i++)
    {
    Console。WriteLine(test[i]+list[test[i]]);
    }

    邵***

    2023-03-06 06:30:00

类似问题

换一换
  • 电脑/网络 相关知识

  • 电脑网络技术
  • 电脑网络

相关推荐

正在加载...
最新资料 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):