我收到错误如下:
mscorlib.dll 中出现“System.FormatException”类型的异常,但未在用户代码中处理
附加信息:字符串未被识别为有效的 DateTime。
这是我的代码:
if (txtRefDate.Text != "")
{
string[] splitdate = txtRefDate.Text.Split('-');
string newdate = splitdate[1] + "-" + splitdate[0] + "-" + splitdate[2];
DateTime Compdate = Convert.ToDateTime(newdate);//On this line i'm getting error
string date = Compdate.ToString("yyyy-MM-dd");
obj.RefrenceDate = Convert.ToDateTime(date);
}
我CalenderExtender在我的textbox. 我试过Parse和ParseExact,但它不起作用。我在这里做错了什么?
相关分类