尝试从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感谢您的回复。在原始文章的底部添加了上面的其他详细信息。 –