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?
{get; set;}
so ifnull
is ever set (or attempts to returnnull
in the getter) it instead uses an empty array. EDIT: Just be sure if you do the check on theget
to also store the empty array in the backing field rather than just returning a new instance. – Chris Sinclair yesterdaynull
and set them to a new instance of their appropriate empty collection. Have it run through this utility when calling your central deserialization method. – Chris Sinclair yesterday