XML Serialization to use empty array instead of NULL

.net, c#, serialization, xml, xml-serialization

Solution

5 years later... :) Replacing Array with List<> did the trick for me.

[XmlElement (IsNullable = false)]
public List<string> Emails {get;set;}

Problem

I have a property ``` [XmlElement] public string[] Emails { get; set; } ``` which is initialized as string[0] at constructor. If I XML serialize and deserialize a default instance of this object, the property is NULL. How can I tell the XML Serializer to use an empty array instead of NULL for this property?

Original source