|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to deserialize null collectionsThere appears to be a difference in how null arrays and collections are deserialized using XmlSerializer. A null array is serialized into nothing, then deserialized back to null again (which one could argue is the correct behaviour), while a collection is serialized into nothing (like the array) but then deserialized into a collection instance with 0 elements. Obviously, you'd have trouble telling the difference between a null collection and an empty one after serilization. For example, the class below would deserialize to an instance with MyArray = null and MyCollection = StringCollection with 0 elements (the data members could just as well be properties). public class Foo { public string[] MyArray = null; public StringCollection MyCollection = null; } Is there a solution or at least a workaround to this problem? Cheers, Ryan |
|||||||||||||||||||||||