How to Write Generic Method to Deserialize object from XML in C#

14 Apr 2014, 07:21 AM

Generic is very powerful concept in C#. it is very simple to write the generic XML deserializer in .Net framework. See the method written below.

 
public static T DeSerialize<t>(string xmlString) { var reader = new StringReader(xmlString); var serializer = new System.Xml.Serialization.XmlSerializer(typeof(T)); var instance = (T)serializer.Deserialize(reader); return instance; }

Related Contents

15 May 2014, 08:07 AM
C#, LINQ, List
15 May 2014, 07:54 AM
C#, LINQ, List
29 Apr 2014, 03:07 AM
C#, Generic
About
Explains how to write generic method to create object from the XML deserialize.

Date Posted 14 Apr 2014, 07:08 AM
Author Brainy Solutions
Views 2,330
;