I met some problem that I tried to retrieve the particular value with its key.
For example: I have a Dictionary(Of String, Double) {“AA”, 0.1}, {“BB”, 0.2},
but I failed when I used Value = Dictionary(“BB”)
I searched some case but I felt confused.
A case said that the variable type of Dictionary is KeyValuePair<Of String, Double> if I
want to use dictionary.
Did I use the wrong Data Type, not the Dictionary<Of String, Double>, but the KeyValuePair<Of String, Double>?
Is Dictionary and KeyValuePair are the same thing?
I couldn’t find the error message appeared yesterday, but it seems have some new problems now.
After I changed the variable type of my dictionary variable from dictionary to KeyValuePair yesterday, right now even I changed it back , but the error message keeps showing me that "For Each: Unable to cast object of type 'System.Collections.Generic.KeyValuePair2[System.String,System.Double]' to type 'System.Collections.Generic.Dictionary2[System.String,System.Double] "
I tried For each and while tried to solve the problem but they didn’t work.
Please provide me some advice or point out where I was wrong
Thank you everyone!
Best way to iterate dictionary is to use KeyValuePair.
The dictionary stores key-value pairs. So you can use a KeyValuePair<TKey, TValue> type or an implicitly typed variable var in foreach loop
Dictionary elements can be accessed by many ways e.g. foreach, for loop or indexer.
@opas sorry for my delayed answer due i am travelling.
The community gave you the hints and I hope you get work. feel free to come back in case other issues occured
Can anyone help me with array of Dictionaries. How can I add a new dictionary to the array of dictionary ?
Eg: I have initialized a array of dictionary as ArrayOfDict
Now what I want is to add a dictionary to this array dynamically as I get the data from another process.
I was trying to use the Add to Dictionary activity, however could not find what should I pass as dictionary name. I tried it as ArrayOfDict(1) , ArrayOfDict[1].
Nothing is helping.
Request to provide any assistance on this.
Thanks in advance!