想测试一下定义好的全局变量字典,怎么会出现这么个问题?
1、代码
Dim dr As DataRow
Dim dt As DataTable
Vars("字典1") = New Dictionary(of String,String) ' 定义 字典
dt = DataTables("表C")
For i As Integer = 0 To 2
dr = dt.DataRows(i)
Vars("字典1").Add(dr("A列"),dr("场所"))
Next
For Each s As String In Vars("字典1").Keys
Output.Show(s)
Next
Output.Show("")
For Each s2 As String In Vars("字典1").Values
Output.Show(s2)
Next
2、结果
在命令窗口执行代码,得到这个结果:
3、问题
表中行是按 0-2 的顺序遍历的,但是为什么会跳过产品B、C、D所在的3行,而给出了产品A、E、F 3行 的数据呢?
表C中的内容:

此主题相关图片如下:字典测试.jpg
