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 could add an implicit type conversion operator:
public class DoubleClass
{
public double X;
public double Y;
public double Z;
public static implicit operator FloatClass(DoubleClass d)
{
return new FloatClass { X = (float)d.X, Y = (float)d.Y, Z = (float)d.Z };
}
}
Now this works:
DoubleClass doubleObject = new DoubleClass();
FloatClass convertedObject = doubleObject;