namespace Tanshu.Common.Helpers { public enum Align { Left = 1, Centre = 2, Right = 4 } public static class StringHelper { public static string Center(this string input, int width) { if (input.Length > width) return input; var left = ((width - input.Length) / 2) + input.Length; input = string.Format("{0,-" + left + "}", input); return string.Format("{0," + width + "}", input); } public static string Center42(this string input) { return Center(input, 42); } } }