Warum tut (int)(object)10m werfen "die Angegebene Umwandlung ist ungültig" Ausnahme?

Warum diese explizite cast macht werfen Specified cast is not valid. Ausnahme ?

decimal d = 10m;
object o = d;
int x = (int)o;

Aber das funktioniert:

int x = (int)(decimal)o;

InformationsquelleAutor Homam | 2010-10-17

Schreibe einen Kommentar