Here is my class:
public class Command
{
[XmlArray(IsNullable = true)]
public List<Parameter> To { get; set; }
}
When I serialize an object of this class:
var s = new XmlSerializer(typeof(Command));
s.Serialize(Console.Out, new Command());
it prints as expected (xml header and default MS namespaces are omitted):
<Command><To xsi:nil="true" /></Command>
When I took this xml and tried to deserialize it I got stucked, because it always print "Not null":
var t = s.Deserialize(...);
if (t.To == null)
Console.WriteLine("Null");
else
Console.WriteLine("Not null");
How to force deserializer to make my list null, if it is null in xml?