I have InvalidCastException when I try to cast 0.0 to double, why is that so? It\'s fine when I do (float)value instead.
InvalidCastException
(float)value
That's normal. If the object type is float you cannot cast it to double because they are not of the same type:
float
double
object o = 1.0f; double d = (double)o; // will throw an exception
You need to convert it:
double d = Convert.ToDouble(o);