Replacing words in a string with values from Dictionary in c#
问题 I have a simple dictionary like this: var fruitDictionary = new Dictionary<string, string> {Apple,Fruit}, {Orange, Fruit}, {Spinach, Greens} and I have a string like var fruitString = Apple Orange Spinach Orange Apple Spinach How to replace all occurrences of the particular word in that sentence with the matching-word from the dictionary? (i.e.) The above sentence should read Fruit Fruit Greens Fruit Fruit Fruit ? Any ideas is much appreciated. EDIT: I tried something like this: var