So tonight I asked a question about storing date time formats in the Application Settings system of .NET. The answer I got makes sense but got me thinking about another situation.
This is only hypothetical, I may not find myself in need of using this but it would be interesting to know what the common answer is.
It seems the Settings system converts a datetime into the "The General Date Long Time ("G")" format (see Standard Date and Time Format Strings on MSDN) which is fine if that is all you want but what if you want to store a value using the "The Round-trip ("O", "o")" format?
As far as I can see at the moment you would need to store that as a string and parse it yourself. Is that the only way when using the designer?
The fastest and most efficient way of losslessly serializing a DateTime
is using the ToBinary and FromBinary methods.
settings.Timestamp = date.ToBinary();
// ...
DateTime date = DateTime.FromBinary(settings.Timestamp);