Because the XmlSerializer deserializes an object by instantiating it (hence
the need for a default constructor) and then populating all of its
properties that can be written to. That's why the XmlSerializer won't
retain state for private members or any property that cannot be written to.
If you need an object that completely maintains its state (private members)
and does not rely on a default constructor, you should look at the
BinaryFormatter or the SoapFormatter. These can be found respectively in
the System.Runtime.Serialization.Formatters.Binary or
System.Runtime.Serialization.Formatters.Soap namespaces.
--
Ben Lucas
Lead Developer
Solien Technology, Inc. www.solien.com
Anuj Gupta via .NET 247 said:
Can anyone please suggest 'why it is must to have a defualt constructor
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.