I have two classes which have are nearly equal except the data types stored in them. One class contains all double values while other contains all float values.
Best way for Convert
public static class Extention {
public static string ConvertObjectToJson(this object ob)
{
return JsonConvert.SerializeObject(ob);
}
}
For Usage
var doubleClass = new DoubleClass {
x = 10,
y = 20
};
var floatClass = JsonConvert.DeserializeObject<FloatClass>(doubleClass.ConvertObjectToJson());