PrepAway - Latest Free Exam Questions & Answers

What should you do?

You have recently created a serializable class named Vehicle.
The class is shown below:
[Serializable]
public class Vehicle{
public string VIN;
public string Make;
public string Model;
public string Year;
}
You are planning to create a custom formatter class to control the formatting of Vehicle objects when they are serialized.
You need to ensure that is achieved with as little development effort as possible.
What should you do?

PrepAway - Latest Free Exam Questions & Answers

A.
Use the following code:
public class VehicleFormatter : Formatter{
//Implementation omitted
}

B.
Use the following code:
public class VehicleFormatter : IGenericFormatter{
//Implementation omitted
}

C.
Use the following code:
public class VehicleFormatter : IFormatConverter{
//Implementation omitted
}

D.
Use the following code
public class VehicleFormatter : IFormatter{
//Implementation omitted
}

Explanation:
When implementing the IFormatter interface, you must provide implementation for two methods and three properties.
The two methods, Serialize and Deserialize control how objects will be stored from memory and loaded into
memory, respectively. Both methods accept a Stream object as an argument. The Serialize method also takes a generic object as its second argument and uses the Stream argument to write the object.
The Deserialize method returns the object using the Stream argument. The Binder, Context, and Surrogate Selector properties must also be implemented.
Incorrect Answers:
A: The Formatter class requires more development effort than necessary.
B: The IGenericFormatter interface does not exist.
C: The IFormatConverter interface does not control formatting during serialization.

One Comment on “What should you do?


Leave a Reply