c#中关于时间转换提供了两种方法:DateTime.ParseExact()和 Convert.ToDateTime(string),ParseExact使用起来会更加灵活,可以由用户自己来定义时间格式,比如数据库里某字段的值都是20071225这种形式,我们可以这样转换:
DateTime time1 = DateTime.ParseExact(dt,"yyyyMMdd", null);
dt为这样的字符串:"20071225
来自:http://www.cn-web.com/shtml/article/net/csharp/2009/02/04/421.shtml
本文介绍了C#中两种时间转换的方法:DateTime.ParseExact() 和 Convert.ToDateTime(string)。重点讲解了 ParseExact 的灵活性及其应用场景,例如如何将特定格式的字符串转换为日期时间类型。
7336

被折叠的 条评论
为什么被折叠?



