Answer: In
C#, We can convert the instances of compatible types, which creates a new value from the old one.
Explicit conversions
cast to convert.
Example,
int x = 5;
short y = (short)x;
In the above example, we are converting a
32 bit integer (
int) to a
16 bit integer (
short) by using
cast (short) of that type.
Explicit conversions doesn't need any guarantee of the compiler for the successful conversion.
There might be a loss of information while converting explicitly.
Asked In: Spotted While Learning |
Alert Moderator