Looking at Convert , you can see that it relies on IConvertible , implemented by types that are converted. The IConvertible interface forces the type to implement all conversion methods, and it should work as you described:
If there is no meaningful conversion to a common language runtime type, then a particular implementation of the interface method raises an InvalidCastException .
Thus, the method in question exists in the Convert class, probably because all IConvertible must have this method:
public static int ToInt32(DateTime value) { return ((IConvertible)value).ToInt32(null); }
So, it seems like others have noted, it seems that this is a matter of consistency with the IConvertible interface and completeness. A Convert implementation can even be generated, as it relies only on IConvertible .
Bartoszkp
source share