- Create a class called Vehicle. You will notice that this class implements ISerializable while still having the [Serializable] attribute. You must do this so that the Common Language Runtime can identify this class as serializable:
[Serializable] public class Vehicle : ISerializable { }
- To this class, add the following fields and the constructor:
// Primitive fields public int VehicleType; public int EngineCapacity; public int TopSpeed; public Vehicle() { }
- When you implement ISerilizable on your Vehicle class, Visual Studio will alert you that the ISerializable interface has not been implemented inside your class. Add the implementation by clicking on the lightbulb next to the underlined interface name and accepting ...