首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

如何循环得到Dictionary的key值

2012-09-15 
怎么循环得到Dictionary的key值?VB codeDim dic As New Dictionary(Of String, String)dic.Add(111, )

怎么循环得到Dictionary的key值?

VB code
Dim dic As New Dictionary(Of String, String)dic.Add("111", "")dic.Add("32", "")

  我现在要把这两个key值放到textbox1中去,key之间用vbcrlf分开 要怎么写呢?(是要key值不是item的值.)

  我这样写它报错:No default member found for type 'KeyCollection'.
一定要先另外弄个数组k才能把key取出来吗?这么麻烦?
VB.NET code
  Dim k        k = dic3.Keys        For i = 0 To dic3.Count - 1            TextBox1.Text = TextBox1.Text + k(i)+vbcrlf        Next




谢谢!!


[解决办法]
VB code
Dim dic As New Dictionary(Of String, String)        dic.Add("111", "")        dic.Add("32", "")        For Each k In dic.Keys            ...        Next 

热点排行