Why this explicit cast does throw Specified cast is not valid. exception ?
decimal d = 10m;
object o = d;
int x = (int)o;
But this works:
int x = (int)(decimal)o;
Why this explicit cast does throw Specified cast is not valid. exception ?
decimal d = 10m;
object o = d;
int x = (int)o;
But this works:
int x = (int)(decimal)o;