Consider this code (exceeded by example):
DateTime dt1 = DateTime.Parse("7/30/2010 9:33:29.1234567 AM");
DateTime dt2 = DateTime.Parse("6/30/2010 9:33:00.7654321 AM");
TimeSpan ts = dt1 - dt2;
Console.WriteLine(string.Format( "{0:d.hh:mm:ss.ff}", ts ));
This is part of the code that I have been working with .NET 1.1 at least.
It worked perfectly in versions 1.1 through 3.5 with the following output (for these nested inputs):
30.00:00:28.3580246
But now I see that he is dying in .NET 4 with an error message:
Input string was not in a correct format.
So, as if .NET 4 had suddenly decided that this format is not suitable for time differences. Change the line let's say
Console.WriteLine(string.Format( "{0}", ts.ToString("d.hh:mm:ss.ff") ));
has the same effect.
Now I noticed that if I just do the default .ToString(), I get the same result. I believe that the thought process was that it was an insurance policy against changing the default format in a future version. But now it doesn’t even seem like an option.
- , , - , ?