You have recently created a serializable class named Vehicle.
The class is shown below:
[Serializable]
public class Vehicle {
public string VIN;
public string Make;
private string Model;
private int Year;
private string Owner;
}
Domain.com does not want the Owner field to be persisted when a Vehicle object is serialized, for security reasons.
You need to ensure that this objective is fulfilled.
What should you do?
A.
Apply the OptionalField attribute to the Owner field.
B.
Apply the NonSerialized attribute to the Owner field.
C.
Have the Vehicle class implement the IFormatter interface for custom serialization.
D.
Do nothing because, when using binary serialization, Private fields are never persisted.
Explanation:
This will ensure that the Owner field will not be serialized, but it will allow all other fields to be serialized normally.
Incorrect Answers:
A: This option would be used for deserialization.
C: This option would require excessive developer effort.
D: This is incorrect because all fields marked private or otherwise are persisted when using binary serialization.
I have the same idea. B