using System; using System.Text; using System.Text.RegularExpressions; using System.Collections.Generic; public class Test { public static string Format(string formatWithNames, IDictionary data) { int pos = 0; var args = new List(); var fmt = Regex.Replace( formatWithNames , @"(?<={)[^}]+(?=})" , new MatchEvaluator(m => { var res = (pos++).ToString(); var tok = m.Groups[0].Value.Split(':'); args.Add(data[tok[0]]); return tok.Length == 2 ? res+":"+tok[1] : res; }) ); return string.Format(fmt, args.ToArray()); } public static void Main() { var x = new Dictionary { {"brown", 123} , {"jumps", 21} , {"lazy", 42} }; Console.WriteLine("{0}", Format("Quick {brown} fox {jumps:C} over the {lazy:P} dog", x)); } }