I Have A List (Fleet) Which Stores Instances of A Class (Transport) which is more specifficly (Car ,Minibus ,Truck)
The Problems Occuring are , whilst attempting to use XML i have no parameterless contructor, and using binary it cannot explictly change Fleet to Transport
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
namespace SD2coursework
{
[Serializable()]
public class Fleet
{
/*
* This class is used to hold a list of Car objects that make up the fleet:
* The car objects may be added through the addToFleet() method.
* The car objects may be deleted tgrough the deleteFromFleet() method
* Use the fleet property to access the list of car objects
*/
public List<Transport> theFleet = new List<Transport>(); //The list of car objects being stored
public List<Transport> fleet
/* The fleet property. Note that you can only read it
* use the addToFleet and deleteFromFleet to update it
*/
{
get
{
return theFleet;
}
}
public void deleteFromFleet(Transport a)
//Delete car from fleet
{
theFleet.Remove(a);
}
public void addToFleet(Transport a)
//Add car to fleet
{
theFleet.Add(a);
}
}
}
Comment