有关 yyy 格式的文档 指出它应该是 3 个或更多数字。那么为什么以下代码会抛出异常?请注意保留 html 标记。
string format = "dd.MM.yyy";
string s = DateTime.Now.ToString(format, CultureInfo.InvariantCulture);
DateTime d = DateTime.ParseExact(s, format, CultureInfo.InvariantCulture); //this throws FormatException
ToString()
为基础进行撰写的。有几个地方表明Parse
系列方法更为严格。 - Damien_The_Unbeliever