April 2013
Intermediate to advanced
1700 pages
92h 51m
English
Simply stated, conversions are a way to treat an expression as being of a specified type. This gives rise to two different situations: Either the conversion is statically known by the compiler to be safe (no data loss can occur) or such guarantees do not exist.
In the former case, implicit conversions are permitted by the compiler. Primitive types form a good playground to illustrate this. For example, given an int variable, it’s possible to treat it as if it were a long because all Int32 values definitely fit in the range of the Int64 type. This particular conversion is a representation-changing conversion that needs runtime assistance because we’re stuffing a 4-byte value in an 8-byte one:
Read now
Unlock full access