F
Francois Malgreve
in the following code:
object obj = this.ViewState["currentCreditLimit"];
string s = obj.GetType().ToString();
currentCreditLimit = (double) this.ViewState["currentCreditLimit"];
ViewState is a StateBag object (dictionary type object)
the String s shows me that the type is System.Int32, the value contained is
0 ( I can see it in the debugger)
I understand well that a double can contain bigger values than what contain
an Int32 but I do not understand why I got a casting exception. As I think
that you can cast any number types into any others. The only risk being to
overflow the capacity of the target type. Which is not the case here as my
value is 0.
Also, if I do something like the following it will run fine.
int i = 0;
double d = 0;
d = i;
Could someone explain me what is going on?
Thanks
Francois
object obj = this.ViewState["currentCreditLimit"];
string s = obj.GetType().ToString();
currentCreditLimit = (double) this.ViewState["currentCreditLimit"];
ViewState is a StateBag object (dictionary type object)
the String s shows me that the type is System.Int32, the value contained is
0 ( I can see it in the debugger)
I understand well that a double can contain bigger values than what contain
an Int32 but I do not understand why I got a casting exception. As I think
that you can cast any number types into any others. The only risk being to
overflow the capacity of the target type. Which is not the case here as my
value is 0.
Also, if I do something like the following it will run fine.
int i = 0;
double d = 0;
d = i;
Could someone explain me what is going on?
Thanks
Francois