C#中填充字符串的运用
时间:2014-03-17 17:55 来源: 我爱IT技术网 作者:山风
填充字符串
有了插入字符串,还整个填充,看看string多周到......PadLeft和PadRight可分别在字符串的左侧和右侧进行填充!不过填充的是字符...字符!
语法格式:Public string PadLeft(int totalWidth,char paddingchar);
PadRight 同上;
string loong = "金七情是龙的传人";
Console.WriteLine("使用左侧填充字符串方法PadLeft:");
loong = loong.PadLeft(10, '~');
Console.WriteLine(loong);
Console.WriteLine("使用右侧侧填充字符串方法PadRight:");
loong=loong.PadRight(12,'!');
Console.WriteLine(loong);
Console.ReadLine();
结果:
本文来源 我爱IT技术网 http://www.52ij.com/jishu/4144.html 转载请保留链接。
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
