Deserialize Object from XML String - CSharp System.Xml

CSharp examples for System.Xml:XML Serialization

Description

Deserialize Object from XML String

Demo Code


using System.IO;/*ww w. j a v  a  2  s .c o  m*/
using System.Xml.Serialization;

public class Main{
        public static T DeserializeObject<T>(string toDeserialize)
        {
            var xmlSerializer = new XmlSerializer(typeof(T));

            var result = xmlSerializer.Deserialize(new StringReader(toDeserialize));
            return (T)result;
        }
}

Related Tutorials