#1,049 – Full List of Implicit Numeric Conversions

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
Advertisement

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

2 Responses to #1,049 – Full List of Implicit Numeric Conversions

  1. Pingback: Dew Drop – March 10, 2014 (#1739) | Morning Dew

  2. Pingback: #1,054 – Implicit Conversions from Constant Expressions | 2,000 Things You Should Know About C#

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: