C# casting int to float throwing exception (in runtime) -
this throws exception source can't casted destination:
int = 1; object b = (object)a; float c = (float)b; // exception here why?
you can cast boxed structs exact type, you'll need cast int first:
float c = (float)(int)b; however since there's implicit conversion float int, can do:
float c = (int)b;
Comments
Post a Comment