0
Help please
Some one can help me how modify values from a dictionary, in the final exam asked me change the discount but i can use the value to do operations so please help
6 Antworten
+ 1
My solution was successful by looping through the keys, retrieving the values, temporarily calculating the discounted value, then printing the key with the temporary value. I didn't need to update the dictionary values.
+ 1
I used a foreach statement to loop through the keys.
foreach (string menu in coffee.Keys.ToArray)
Then I used the loop index (menu) to look up the value in the dictionary.
coffee[menu]
+ 1
If you want only the values, you can use the .Values property.
https://xwww.geeksforgeeks.org/c-sharp-dictionary-values-property/
0
How can i get the values?
0
I did not understand exactly what you meant. However, if you want to change the value of the dictionary, use this method
Example
myDictionary[myKey] = myNewValue
0
Ok, but It you can use the value for operations?