2

Isn't OnDeserialized redundant with IDeserializationCallback.OnDeserialization

1 Answer 1

4

If you read the documentation on the OnDeserialized attribute and the IDeserializationCallback interface, you'll see that that interface was first implemented in .NET 1.0, while the attribute was added in .NET 2.0, along with a number of additional related attributes that provide more fine-grained control of the serialization / deserialization process.

From the OnDeserializedAttribute remarks section:

This attribute can be used instead of the IDeserializationCallback interface.

So to answer your question, yes, they are redundant. An educated guess would be that the attribute-based markers are the preferred way to do this, as they give you more flexibility and do not require a separate interface to use. The interface is there because if they removed it, it would break backwards compatibility with older code.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.