using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
public class myXML
{
[Serializable]
public class classA
{
[Serializable]
public class classB
{
public int c = 0;
public string d = String.Empty;
}
public List<classB> b = new List<classB>();
}
static public void Main ()
{
classA a = new classA();
for (int i=0; i<2; i++)
{
for (int j=0; j<3; j++)
{
classA.classB b = new classA.classB();
b.c = (i*10) + j;
b.d = ((i*10) + j).ToString();
a.b.Add(b);
}
}
FileStream fs = new FileStream(ファイル名, FileMode.Create, FileAccess.Write);
using (fs)
{
XmlSerializer xmlserializer = new XmlSerializer(typeof(classA));
xmlserializer.Serialize(fs, (object)a);
}
}
}
[Serializable]
[System.Xml.Serialization.XmlType("Aだよん")]
public class classA
{
[Serializable]
[System.Xml.Serialization.XmlType("Bだよん")]
public class classB
{
public int c = 0;
public string d = String.Empty;
}
public List<classB> b = new List<classB>();
}