I have field public TimeSpan TimeSpanField
in myClass. I create instance of the myClass and fill field. Next I want to serialize it to XML and deserialize back to the object. I Know that Microsoft have problems with TimeSpan serialization therefore I found the answer How to serialize a TimeSpan to XML and use it.
ok! It works good. But How to make similar for public TimeSpan[] TimeSpanArrayField
. the indexer(http://msdn.microsoft.com/en-us/library/6x16t2tx.aspx) in this case didn't help.
Code forpublic TimeSpan TimeSpanField
[XmlIgnore]
public TimeSpan TimeSpanField;
[Browsable(false)]
[XmlElement(DataType = "duration", ElementName = "TimeSpanField")]
public string TimeSpanFieldString
{
get
{
return XmlConvert.ToString(TimeSpanField);
}
set
{
TimeSpanField = string.IsNullOrEmpty(value) ?
TimeSpan.Zero : XmlConvert.ToTimeSpan(value);
}
}