static void Main(string[] args) { var wagon1 = new Wagon("Sirius", 1, WagonType.Passenger, 100, 0); var wagon2 = new Wagon("Centrano", 2, WagonType.Trade, 0, 10); Wagon[] wagons = new Wagon[] { wagon1, wagon2 }; var loco = new Loco("Lesser", 10, LocoType.thermal); var train = new Train(3, loco, wagons); XmlSerializer formatter = new XmlSerializer(typeof(Train)); using (FileStream fs = new FileStream("train.xml", FileMode.OpenOrCreate)) { formatter.Serialize(fs, train); } }
public Train(int number, Loco trainLoco, Wagon[] wagons) { Number = number; TrainLoco = trainLoco; Wagons = wagons }