c# 字符串填充占位

C#  字符串PadLeft函数的使用

1.Demo:

需求:

将111改变成0000111

使用字符串PadLeft函数可以解决:

int num = 111;     

string s= num.ToString();

s= s.PadLeft(7, '0');

Console.WriteLine(s);//s输出: 0000111

 

 

posted @ 2015-11-20 16:24  土豆哥  阅读(2412)  评论(0编辑  收藏  举报