0

I am using a data dictionary in VB.NET windows application.

I am trying to get the data from dictionary using the for loop.

ex. I have below dictionary table and I want to get the values using the for loop.

AAA - "0"   
BBB - "0" 
CCC - "0' 
DDD - "0"
 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 

How to do this ?

Nilesh B
  • 121
  • 2
  • 2
  • 7

1 Answers1

0

you do not need to iterate the entire dictionary to test AAA or BBB (they are not Lists or Arrays):

 If CatDictionaryNEW1("AAA") = 0 Then
      do whatever
 End If

 If CatDictionaryNEW1("BBB") = 1 Then
      do whatever
 End If

You would need to walk thru the entire dictionary if you needed to find WHICH item or element contained a certain value:

  For each kvp as KeyValuePair in myDict
       if kvp.Value = MagicValue then
           Return kvp.Key
       End if
  Next
Ňɏssa Pøngjǣrdenlarp
  • 38,411
  • 12
  • 59
  • 178