Conversions
Why is there no implicit conversion?
Because it would remove the type safety brought by the value objects. Let's suppose the following scenario:
The preceding code compiles and does not throw. Also, a conversion that would result in an InvalidCastException
should not be implicit. So it is not allowed to cast from a primitive to a value object but casting a value object to a primitive is always valid. An explicit cast is implemented.
Last updated