Serialize a C# class to xml. Store the XML as a string in SQL Server and then restore the class late
- by BrianK
I want to serialize a class to xml and store that in a field in a database. I can serialize with this:
StringWriter sw = new StringWriter();
XmlSerializer xmlser = new XmlSerializer(typeof(MyClass));
xmlser.Serialize(sw, myClassVariable);
string s = sw.ToString();
sw.Close();
Thats…