将字符串“201804”转换为DateTime
DateTime dTime = DateTime.ParseExact("201804", "yyyyMM", CultureInfo.CurrentCulture);
常见的日期转换
1、Convert.ToDateTime(string date)
date格式为 yyyy-mm-dd hh:mm:ss
2、Convert.ToDateTime(string date, IFormatProvider formatter)
formatter 指日期格式
3、DateTime.Parse(dateInput)
参考 http://www.bubuko.com/infodetail-3293058.html
https://docs.microsoft.com/en-us/dotnet/standard/base-types/parsing-datetime?redirectedfrom=MSDN