The NonSerialized attribute

T

Tony Johansson

Hi!

The NonSerialized attribute has this text as part of its documentation.
"Indicates that a field of a serializable class should not be serialized.
This class cannot be inherited."

But this attribute has also another meaning and that is the following.
If you for example has serialized an object that contains a name field of
type string and than
add this Nonserialized attribute on the name field before deserializing the
file with the object within then this will happen.
The app will not read this name field into the deserialized object so the
object will not contains any name field.

So should'n this information be included in the docs ?

//Tony
 
P

Patrice

Once again see the idea rather than analyzing each word literally. If a
field is not serialized, quite obviously it can't be deserialized as it
would need to have been serialized first. BTW I'm trying right now your
previous scenario. Will post in the appropriate thread...
 
H

Harlan Messinger

Tony said:
Hi!

The NonSerialized attribute has this text as part of its documentation.
"Indicates that a field of a serializable class should not be serialized.
This class cannot be inherited."

But this attribute has also another meaning and that is the following.
If you for example has serialized an object that contains a name field of
type string and than
add this Nonserialized attribute on the name field before deserializing the
file with the object within then this will happen.
The app will not read this name field into the deserialized object so the
object will not contains any name field.

So should'n this information be included in the docs ?

If the class declaration says that the field isn't serialized, then why
would the serializing mechanism look for that field in the archive and
deserialize it into the field?
 

Ask a Question

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.

Ask a Question

Top