public static string Center(this string stringToCenter, int totalLength) { return stringToCenter .PadLeft(((totalLength - stringToCenter.Length) / 2) + stringToCenter.Length) .PadRight(totalLength); }