Wednesday, February 20, 2013

Exclude a property from serialization

Last week I had to serialize a class. The important thing was that I wanted to serialize all values except one. Most of the time I use the following construct:

The [NonSerialized] attribute is only supported on field types, so I had to find another solution. As I was serializing to XML, I decided to use [XMLIgnore] as an alternative:

No comments: