Serialization De-Serialization Common Utilities function

suggest change

This sample used to common function for all type object serialization and deserialization.

using System.Runtime.Serialization.Formatters.Binary;
using System.Xml.Serialization;

namespace Framework
{
	public static class IGUtilities
	{
	    public static string Serialization(this T obj)
	    {
			    string data = JsonConvert.SerializeObject(obj);
			    return data;
	    }
	
	    public static T Deserialization(this string JsonData)
	    {
		    T copy = JsonConvert.DeserializeObject(JsonData);
		    return copy;
	    }
	
	     public static T Clone(this T obj)
	    {
	        string data = JsonConvert.SerializeObject(obj);
	        T copy = JsonConvert.DeserializeObject(data);
	        return copy;
	    }
	}
	}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents