This is second and last part of the post on Nullable type series. You can view the first part from here
Exploring Nullable types : Part 1
In this series, I will talking certain rules that we need to take care while using Nullable type. I will be taking scenario wise.
First scenario:
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.