Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Xml.Serialization;
- using System.IO;
- namespace XmlTest
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool doArray = true; // set to true to change to an array
- Config config = new Config(doArray);
- XmlSerializer serializer = new XmlSerializer(typeof(Config));
- // Writing the document requires a TextWriter.
- TextWriter writer = new StreamWriter("Xmltest" + ".xml");
- // Serialize the object, and close the TextWriter.
- serializer.Serialize(writer, config);
- writer.Close();
- }
- }
- [Serializable]
- [XmlInclude(typeof(MyDataItem))]
- public class Config
- {
- public object tmp;
- public Config()
- {
- }
- public Config(bool doArray)
- {
- MyDataItem o = new MyDataItem();
- if (doArray)
- o.Value = new int[1];
- else
- o.Value = 0;
- tmp = o;
- }
- }
- [Serializable]
- public class MyDataItem
- {
- public object Value;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement