如何获取集合类Dictionary中所有key的值(在线等!!!)

jinsuo_1986 2009-04-09 05:31:57
如题!
...全文
4709 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
yobuke 2012-05-24
  • 打赏
  • 举报
回复
Dictionary<string, string> dic= new Dictionary<string, string>();
foreach (var item in dic.Values)
{
//Do sth.
}
yobuke 2012-05-24
  • 打赏
  • 举报
回复
Dictionary<string, string> dic= new Dictionary<string, string>();
foreach (var item in dic.Values)
{
//Do sth.
}
zisediao325 2011-03-15
  • 打赏
  • 举报
回复
恩 这个可以使用,只是想把它保存到数组里比较麻烦
blue601 2010-12-29
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 zgke 的回复:]
Dictionary<string, string> _Dictionary = new Dictionary<string, string>();
foreach(string _Key in _Dictionary.Keys)
{
_Key
}
[/Quote]

这个我刚刚试过,没有问题 _Key就是你需要的键值
ljhcy99 2009-04-09
  • 打赏
  • 举报
回复
Dictionary <string, string> dic = new Dictionary <string, string>();

dic.keys
ojekleen 2009-04-09
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 heyu52 的回复:]
Dictionary <string, string> dic = new Dictionary <string, string>();

dic.Values <--------值集合
[/Quote]
dic.keys<--------key集合

单个获取可以foreach
如果你的key是string 类型

foreache(string s in dic.keys)
{
console.writeline(s);
}
zgke 2009-04-09
  • 打赏
  • 举报
回复
Dictionary<string, string> _Dictionary = new Dictionary<string, string>();
foreach(string _Key in _Dictionary.Keys)
{
_Key
}

heyu52 2009-04-09
  • 打赏
  • 举报
回复
Dictionary<string, string> dic = new Dictionary<string, string>();

dic.Values<--------值集合

110,499

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧