所以我有一个日期字符串与今天的短日期.例如"1-11-2017"
//Here i convert the HttpCookie to a String
string DateView = Convert.ToString(CurrDay.Value);
//Here i convert the String to DateTime
DateTime myDate = DateTime.ParseExact(DateView, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture);
Run Code Online (Sandbox Code Playgroud)
运行代码后,我收到错误:
FormatExeption未被用户代码处理
mscorlib.dll中出现"System.FormatException"类型的异常,但未在用户代码中处理
附加信息:字符串未被识别为有效的DateTime.