Skip to content

Instantly share code, notes, and snippets.

@peyangu
Created March 15, 2017 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peyangu/3c72030e01ea05a5d79394ab73580e2e to your computer and use it in GitHub Desktop.
Save peyangu/3c72030e01ea05a5d79394ab73580e2e to your computer and use it in GitHub Desktop.
XMLに書き込む処理
public void SaveXml(List<Person> personList)
{
System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(Person[]));
// Data.xmlは保存するファイル名
using (System.IO.FileStream fs = new System.IO.FileStream("Data.xml", System.IO.FileMode.Create))
{
serializer.Serialize(fs, personList.ToArray());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment