I have a dictionary with key value pair, and I need to use String Interpolation and then map the string according to the named parameters. Please help me.
// code removed for brevity
var rawmessage = "Hello my name is {Name}"; // raw message
var dict= new Dictionary<string, object>();
dict.Add("{Name}", response.Name);
I want to be able to do something like:
// Pseudo code
$"Hello my name is {Key}", dict;
Solution I have found till now:
var message = parameters.Aggregate(message,
(current, parameter) => current.Replace(parameter.Key, parameter.Value.ToString()));
And it works fine, but my manager really wants me to use String Interpolation with Dictionary. I am not sure how to achieve this. Please guide me.