❔ Help with Dictionary<string,string>
I have a series of textBoxes to enter strings like first name, last name etc. Each character of the string equals a key in a dictionary. I want to remove the keys and replace with values. Example string "Sally" , each character would be a key.
I want to print the values. I can only use remove and insert methods.
4 Replies
Each character of a string being a dictionary key sounds like an odd setup, but just loop over each character in the string and do a lookup in your dictionary.
It is a homework scenario. thank you for the hint
@chowder
Use a for loop to iterate over each character in the input string. For each character, use the dictionary's get() method to retrieve the corresponding value, and then use the remove() and insert() methods to replace the character with the value. Finally, print the modified string.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.