在本博客中,可以找到一篇《http://www.cnblogs.com/insus/p/7953304.html

它有教大家怎样实现字符串输出进行左齐或者是右对齐。

本篇的方法,超简单,是使用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

相关文章:

  • 2021-09-11
  • 2021-08-30
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2020-03-31
  • 2021-11-08
猜你喜欢
  • 2021-10-26
  • 2022-12-23
  • 2022-01-27
  • 2022-12-23
  • 2021-11-21
  • 2022-02-22
  • 2022-12-23
相关资源
相似解决方案