我正在查看应用程序中的代码(其他人写的),在某些情况下它运行正常,在某些情况下它给出了异常,它实际上是在datetime中转换字符串,这里是代码
//5000 is the year,but what about "1" is it month or day ?,if its month
//then what about the day ?
DateTime time = DateTime.Parse("1.5000");//1.5000 doesn't looks a date to me ?
time.ToString();//returns "1/1/5000 12:00:00 AM"
//where as if I give this string to DateTime.Parse();
time = DateTime.Parse("2341.70");
//FormatException was unhandled
//String was not recognized as a valid DateTime.
Run Code Online (Sandbox Code Playgroud)
一个令人困惑的想法
这个字符串"3.5000"(它与1.5000模式匹配)如何评估,这意味着3-3-5000或1-3-5000,格式模糊不清,令人困惑!
我的问题是,