C#中格式化字符串的运用小结
时间:2014-03-17 17:38 来源: 我爱IT技术网 作者:山风
格式化字符串:记得在学Unity的时候经常喜欢用这个方法,去获取系统时间,然后格式化输出,比较好玩!
语法格式:Public static string Format(string format,object obj);
对于时间的格式化,C#中已经提供了一些用于时间的格式规范!
例:
语法格式:Public static string Format(string format,object obj);
对于时间的格式化,C#中已经提供了一些用于时间的格式规范!
例:
string loong = "金七情";
string dragon = "龙的传人";
Console.WriteLine("使用格式化字符串方法Format:");
string loongs = string.Format(loong + "是" + dragon);
Console.WriteLine(loongs);
DateTime day = DateTime.Now;
string daystr = string.Format("{0:D}", day);
Console.WriteLine("当前日期是:"+daystr);
Console.ReadLine();
结果:
本文来源 我爱IT技术网 http://www.52ij.com/jishu/4141.html 转载请保留链接。
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
