Quantcast
Channel: How to? XML Serialization of a Class Object - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by Yuck for How to? XML Serialization of a Class Object

$
0
0

Your serialization method should look like this:

public static string SerializeAnObject(Object item) {    if (item == null)        return null;    var stringBuilder = new StringBuilder();    var itemType = item.GetType();    new XmlSerializer(itemType).Serialize(new StringWriter(stringBuilder), item);    return stringBuilder.ToString();}

The function above works when I test it like this:

var test = new Flow();var xmlString = SerializeAnObject(test);

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles



Latest Images