I’m trying to deserialize a collection (let’s use order\items for simplicity’s sake) and I'm struggling to get the serializer to differentiate between an empty collection (where the element is specified but not populated) and a NULL collection (where the element isn't specified)
These are my serialization classes :-
public class MyOrderItems : Collection<MyOrderItem>
public class MyOrder
public MyOrderItems Items = null;
XmlSerializer.Deserialize turns this into an empty collection :-
But also this :-
What I need is for the second example to leave "Items" as NULL.
Any suggestion on the simplest\best way of telling the serializer to ignore collections that aren't specified?
I hope that makes sense!