I have to keep time in that format "00:00:23.123213".
So I have tried to use Timespan
[Serializable()]
public class Item
{
public TimeSpan Start { get; set; }
But this field is always empty in the file.
var test = new ContentItems();
var item2 = new Item();
item2.ContentType = ContentTypes.Paragraph;
item2.Data = "Create a new XmlSerializer instance with the type of the test class.";
item2.DataType = DataTypes.Text;
item2.Start = TimeSpan.FromSeconds(6);
item2.End = TimeSpan.FromSeconds(9);
test.Items.Add(item2);
using (var writer = new System.IO.StreamWriter(@"C:\Projects\1.xml"))
{
var serializer = new XmlSerializer(typeof(ContentItems));
serializer.Serialize(writer, test);
writer.Flush();
}
My Question: Which type is better to serialize Time in .NET?