October 9, 2011 Leave a comment
This is second and last part of the post on Nullable type series. You can view the first part from here
In this series, I will talking certain rules that we need to take care while using Nullable type. I will be taking scenario wise.
Int? a=8; object o = a; long d = (long)c;
It will be compiled successfully but will throw and Invalid Cast Exception. Means, you cannot cast it to any other type except the underlying type which is here int although int type can be hold by long.