#1,049 – Full List of Implicit Numeric Conversions
March 10, 2014 2 Comments
You can do an implicit numeric conversion when the conversion would not result in the loss of data. In general, you can go from a “smaller” type (smaller range of values) to a “bigger” type (larger range of values).
Here’s the full list of allowed implicit numeric conversions:
- From sbyte to – short, int, long, float, double, decimal
- From byte to – short, ushort, int, uint, long, ulong, float, double, decimal
- From short to – int, long, float, double, or decimal
- From ushort to – int, uint, long, ulong, float, double, decimal
- From int to – long, float, double, decimal
- From uint to – long, ulong, float, double, decimal
- From long to – float, double, decimal
- From ulong to – float, double, decimal
- From char to – ushort, int, uint, long, ulong, float, double, decimal
- From float to – double