public static void SerializeInventory() { var product = new Product { ProductID = 100, ProductName = "Product Thing", SupplierID = 10 }; var book = new BookProduct { ProductID = 101, ProductName = "How To Use Your New Product Thing", SupplierID = 10, ISBN = "1234567890" }; Product[] products = { product, book }; var inventory = new Inventory { InventoryItems = products }; using (FileStream stream = File.Create(InventoryFileName)) { var serializer = new XmlSerializer(typeof(Inventory), GetInventoryXmlAttributes()); serializer.Serialize(stream, inventory); } }