public static T Deserialize<T>(string xml)
{
var xmlReader = XmlReader.Create(new StringReader(xml), new
XmlReaderSettings());
var xmlSerializer = new XmlSerializer(typeof(T));
var deserializedObject = xmlSerializer.Deserialize(xmlReader);
return (T)deserializedObject;
}
Use it like so:
var foo = Whatever.Deserialize<Foo>(myXml)
No comments:
Post a Comment