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.
You can use Conversion Operators to achieve this.
Fr example:
struct FloatClass
{
public FloatClass(DoubleClass dClass) {
//conversion...
}
...
public static explicit operator FloatClass(DoubleClass dClass)
{
FloatClassd = new FloatClass(dClass); // explicit conversion
return d;
}
}
var convertedObject = (FloatClass)doubleObject;