Groups | Blog | Home
all groups > dotnet xml > march 2005 >

dotnet xml : Serializing private members



Gregory Khrapunovich
3/31/2005 6:41:35 AM
Hi,
I have a class that contains user configuration settings
and I would like to save it on disk when program exits
and restore data when program starts. XmlSerializer seems
like a natural choice. And it works fine. There is only
one problem. All members of the class must be declared
public in order to be serialized. It breaks the
encapsulation and can potentially be a problem (some
members should only be set through functions because they
have side effects).

Is there a way to serialize a private member? Maybe an
attribute?

Thanks in advance.
Mark Rockmann
4/4/2005 5:53:10 PM
You might want to implement the IXmlSerializable interface. BTW, you don't
have to implement the GetSchema() method.

"Gregory Khrapunovich" <greg@a-s-l.com> schrieb im Newsbeitrag
news:113901c535ff$bcd2ee80$a601280a@phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button