Why does (int)(object)10m throw "Specified cast is not valid" exception?

Viewed 25994

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;
4 Answers
Related