c#中关于时间转换提供了两种方法:DateTime.ParseExact()和Convert.ToDateTime(string),ParseExact使用起来会更加灵活,可以由用户自己来定义时间格式,比如数据库里某字段的值都是20071225这种形式,我们可以这样转换:
DateTime time1 = DateTime.ParseExact(dt,"yyyyMMdd", null);
DateTime time1 = DateTime.ParseExact(dt,"yyyyMMdd", null);
dt为这样的字符串:"20071225"

