嘗試從QueryString的兩個部分一起解析日期(DateTime)和時間(字符串)時收到「錯誤格式」錯誤。使用時間解析日期時間(字符串)
任何幫助讚賞解決此問題。謝謝!下面
var EventStartDate = Convert.ToDateTime(Request.QueryString["date"]);
string EventStartTime = Request.QueryString["time"];
DateTime newDateTime =
EventStartDate.Add(TimeSpan.ParseExact(EventStartTime, "H:mm:ss", null));
更多細節...
EventStartDate = 3/5/2016 12:00:00 AM
EventStartTime = 8:00:00 PM
Error:
Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: Input string was not in a correct format.
Source Error:
Line 8: string EventStartTime = Request.QueryString["time"];
Line 9:
Line 10: DateTime newDateTime = EventStartDate.Add(TimeSpan.ParseExact(EventStartTime, "hh:mm:ss", null));
Request.QueryString [「date」]和Request.QueryString [「time」]'_exactly_?的值是什麼? –
@SonerGönül感謝您的回覆。在原始文章的底部添加了上面的其他詳細信息。 –