What should you do?

You develop a serializable class for persisting objects as files.
Every time an object is serialized, you have to update the database with the name of the object and location of that file.
You elect to employ the OnSerialized attribute to achieve this objective.
You now need to apply the OnSerialized attribute to a certain method.
What should you do?

You develop a serializable class for persisting objects as files.
Every time an object is serialized, you have to update the database with the name of the object and location of that file.
You elect to employ the OnSerialized attribute to achieve this objective.
You now need to apply the OnSerialized attribute to a certain method.
What should you do?

A.
Apply the OnSerialized attribute to the following method:
public void AfterSerialization (object sender, SerializationEventArgs e){
//Update database
}

B.
Apply the OnSerialized attribute to the following method:
public void AfterSerialization (object sender){
//Update database
}

C.
Apply the OnSerialized attribute to the following method:
public void AfterSerialization (StreamingContext context){
//Update database
}

D.
Apply the OnSerialized attribute to the following method:
public StreamingContext AfterSerialization (){
//Update database
}

Explanation:
This method contains the correct method signature to have the OnSerialized attribute applied. The method must accept a StreamingContext as an argument for accessing the read/write stream during serialization/deserialization.
Incorrect Answers:
A, B, D: You should not apply the OnSerialized attribute to these methods because they do not accept a StreamingContext as an argument.



Leave a Reply 1

Your email address will not be published. Required fields are marked *


networkmanagers

networkmanagers

I agree with the answer. C