using System.Text.RegularExpressions;
public static void Main()
Console.WriteLine(strings.Format("Hello World {1} {2} {3} {0}", x, "a", "b", "c"));
public static class strings
public static string Format(this string value, params object[] args)
return Regex.Replace(value, @"\{\d+\}", match =>
var digits = match.Value.Substring(1, match.Value.Length - 2);
if (int.TryParse(digits, out var index) && index < args.Length)
Console.WriteLine(digits + " = " + args[index]);
return args[index]?.ToString() ?? string.Empty;
Console.WriteLine("a" + match.Value);