Tuesday, November 06, 2007

C# Gotcha

Look at the code below..do you see anything wrong?

Object x=2;
double y=(double)x;
Now try to execute it ..and surprise ,surprise it throws a exception...
Looking only at this two lines makes it easier to see the problem..but imagine
this in the middle of a very big code and the error only happening at your production server
(that's what happened to me...) I had to take a wild guess at what was wrong
and I changed the code to
Now the code works.

Powered by ScribeFire.

No comments: