它有教大家怎样实现字符串输出进行左齐或者是右对齐。
本篇的方法,超简单,是使用string.Format()对本进行格式化输出即可。


class Ad { private string[] myVar; public Ad(string[] myValue) { this.myVar = myValue; } public void PadLeft() { foreach (string s in this.myVar) { string s2 = String.Format("{0,13}", s); Console.WriteLine(s2); } } }Source Code
上面的数字“13”就是占位符,正数是靠右对齐,反之,负数是靠左对齐:
随时随地看视频