爲什麼此代碼拋出異常?帶有自定義DateTimeFormatInfo的DateTime.Parse拋出異常
var dateTime = "2012-03-21_15.12";
var format = new DateTimeFormatInfo()
{
FullDateTimePattern = "yyyy-MM-dd-HH_mm.ss"
};
// FormatException: String was not recognized as a valid DateTime.
var parse = DateTime.Parse(dateTime, format);
你假設'DateTime.Parse'方法將使用'FullDateTimePattern'。 – Oded 2012-03-22 12:10:18