Car car1 = new Car();
car1.CarMake = "Ford";
car1.CarModel = "Mustang GT";
//1. Serialization to a file
Stream stream = File.Open("CarInformation.txt", FileMode.OpenOrCreate);
BinaryFormatter bform = new BinaryFormatter();
bform.Serialize(stream, car1);
stream.Close();
//2. Serialization to an XML file
XmlSerializer xmlSer = new XmlSerializer(typeof(Car));
TextWriter writer = new StreamWriter("CarInformation.xml");
xmlSer.Serialize(writer, car1);
为什么不对XML进行序列化需要一个对象' Car'被宣布为' Serializable'而第一组语句抛出SerializationException?