De Serialize Entity from XML - CSharp System.Xml

CSharp examples for System.Xml:XML Serialization

Description

De Serialize Entity from XML

Demo Code


using System.Xml.Serialization;
using System.Xml.Linq;

public class Main{
        public static TEntity DeSerializeEntity<TEntity>(string serialisedEntity)
        {/*www.j a  v a 2 s.  c  o  m*/
            var document = XDocument.Parse(serialisedEntity);
            var serializer = new XmlSerializer(typeof(TEntity));
            var result = (TEntity)serializer.Deserialize(document.CreateReader());
            return result;
        }
}

Related Tutorials