Vb.net 如何在数据字典中使用索引?

Vb.net 如何在数据字典中使用索引?,vb.net,vb.net-2010,Vb.net,Vb.net 2010,我正在VB.NET windows应用程序中使用数据字典 我正在尝试使用for循环从字典中获取数据 例如,我有下面的字典表,我想使用for循环获取值 如何做到这一点 您不需要迭代整个字典来测试AAA或BBB(它们不是列表或数组): 如果需要查找包含特定值的项或元素,则需要遍历整个字典: For each kvp as KeyValuePair in myDict if kvp.Value = MagicValue then Return kvp.Key

我正在VB.NET windows应用程序中使用数据字典

我正在尝试使用for循环从字典中获取数据

例如,我有下面的字典表,我想使用for循环获取值


如何做到这一点

您不需要迭代整个字典来测试AAA或BBB(它们不是列表或数组):

如果需要查找包含特定值的项或元素,则需要遍历整个字典:

  For each kvp as KeyValuePair in myDict
       if kvp.Value = MagicValue then
           Return kvp.Key
       End if
  Next

你能展示一下你是如何声明字典的,以及你是如何添加到字典中的吗?
 For i As Integer = 0 To CatDictionaryNEW1.Count
' for each i I want to fetch the values using index of data dictionary
' when i = 0 then AAA should return
' when i =1 then BBB should return 
' and so on....
 next 
 If CatDictionaryNEW1("AAA") = 0 Then
      do whatever
 End If

 If CatDictionaryNEW1("BBB") = 1 Then
      do whatever
 End If
  For each kvp as KeyValuePair in myDict
       if kvp.Value = MagicValue then
           Return kvp.Key
       End if
  Next