2

我有一个在 .NET 2.0 和 4.0 中表现不同的小应用程序。

DateTime.Parse().NET 2 和 .NET 4 之间有什么变化吗?以下代码段在每个上的行为不同。

// when targeted for .NET 2.0, this prints out: 21/03/2012...,
// which is correct presentation for my regional settings
//
// however, when compiled for .NET 4.0, this throws a FormatException
// {"String was not recognized as a valid DateTime."}

var it = CultureInfo.CreateSpecificCulture("it-It");
Console.WriteLine(DateTime.Parse("21-mar-2012", it));

编辑:

我正在对这些类型的问题的代码库进行一些清理。我试图引发失败,但我惊讶地发现我的测试应用程序(.NET 4)抛出,但实际应用程序(.NET 2)工作正常。

4

0 回答 0