C# How to

XML

  • How to serialize an object to XML by using Visual C#
    • Mark an class with the attribute [Serializable];
    • XmlSerializer x = new XmlSerializer(SomeObject.GetType());
      using (FileStream stream = System.IO.File.Create(FilePath))
      {
      XmlWriter writer = XmlWriter.Create(stream);
      x.Serialize(writer, SomeObject);
      }

Assembly

Visual Studio

Misc

WinForm

Leave a Reply