Can someone tell me why this is happening?
Because this is documented behavior:
Be it Convert.ToDouble(Object) or Convert.ToDouble(Double) , the documentation says quite clearly:
(Under the return value)
A double-precision floating-point number equivalent to a value, or zero if the value is zero .
As always, if reality does not meet expectations, the first thing you should do is check if your expectations are consistent with documented behavior.
He may have a genuine reason why he behaves this way.
Some people claim:
I donβt think there are good reasons for this.
This may be the right opinion, but if the framework designers genuinely believed that returning zero was not an ideal result, they should have done everything they considered the best.
Obviously, once the behavior was defined in .NET, it could not be changed for later versions - but this is not the same as saying that it should behave just like VB6.
source share