Getting 'DateTime.ToString()' to output the same string as an XML serialization of a 'DateTime'

.net, c#, datetime, formatting

Solution

.ToString("o") seemed to do the trick

Problem

Is there a standard `DateTime` format for use in C# that can be used with the `ToString` method that will produce the same format that is produced when you serialize a `DateTime` to XML? For example: `2013-03-20T13:32:45.5316112Z`

Original source