"Beorne" <ma*******@gmail.comwrote in message
news:11**********************@m58g2000cwm.googlegr oups.com...
I'm serializing a big class using XmlSerializer (I need xml
serialization cause compact framework). I've learn that all my fields
must be public. Ok.
Now it is completly useless to serialize my get/set properties, but I
haven't found an anttribute like
[NonSerialized]
working foer properties.
Why do you think all your fields must be public? When I serialize objects
to XML using he XmlSerializer, my fields are private and the serializer
works off of the public properties. The help documentation from MSDN
confirms this is the correct behavior - "The Serialize method converts the
public fields and read/write properties of an object into XML".
So leave your fields private, and have them accessible through public
properties, noting that the get and set must both be public.
That being said, if you want the XmlSerializer to not serialize a property
or field, add an XmlIgnoreAttribute to it.
--
Tom Porterfield