String
|
public static string Interpolate( this string format, IEnumerable<KeyValuePair<string, Object>> parameters )
This overload is intended to be used for scenarios in which the parameters available to the format string are stored in a DictionaryTKey, TValue or ExpandoObject. Note that dynamic variables cannot be used when calling extension functions.
string format = "{hello} {world}!"; dynamic parameters = new ExpandoObject(); parameters.hello = "Hello"; parameters.world = "World"; Console.WriteLine(format.Interpolate(parameters)); // This raises a compiler error Console.WriteLine(format.Interpolate((ExpandoObject)parameters); // This is okay Console.WriteLine(StringExtensions.Interpolate(format, parameters); // This is also okay