Conversions between built-in value types is commonplace. Some built-in conversions are implicit and some have to be explicitly done through cast operations. Here are some examples:
byte b = 255; int i = b; // implicit conversion double d = i; // another implicit conversion decimal dm = (decimal)d; // explicit conversion
What if we try to do type conversion while unboxing? Putting another way - what is the outcome if we unbox a value to a different value type?
object ob = b; // box byte 'b' from above // unbox b to an int int ubi = (int)ob;
What would be the value of ubi?