控制台程序输出中文字符如何实现左或者右对齐输出?
如题所示
程序代码:
const int CONSOLE_WIDTH = 80; const int MAX_WIDTH = CONSOLE_WIDTH - 1; string output = string.Format("{0}\n{1}\n{2}\n{3}", "some stuff", "more stuff", new string('a', 100), "some other stuff...") .Split('\n') .SelectMany(s => Enumerable.Range(0, s.Length / MAX_WIDTH + 1).Select(i => s.Substring(i * MAX_WIDTH, Math.Min(s.Length - i * MAX_WIDTH, MAX_WIDTH)))) .Select(s => s.PadLeft(MAX_WIDTH)) .Aggregate((s1, s2) => s1 + "\n" + s2);