小编Sen*_*alk的帖子

解析具有单个数字日的日期字符串,例如1-11-2017以及12-11-2017

所以我有一个日期字符串与今天的短日期.例如"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.

c# datetime

1
推荐指数
2
解决办法
5720
查看次数

标签 统计

c# ×1

datetime ×1