Home > Articles

  • Print
  • + Share This
This chapter is from the book

Understanding Operator Promotion

Implicit conversions are also associated with operator promotion, which is the automatic conversion of an operator from one type to another. When you do basic arithmetic operations on two variables, they are converted to the same type before doing the math. For example, if you add a byte variable to an int variable, the byte variable is promoted to an integer before it is added.

A numeric variable smaller than an int is promoted to an int. The order of promotion after an int is as follows:

int
uint
long
ulong
float
double
decimal

NOTE

The following section contains advanced material that is not critical to know at this time. You can cover this material now, or you can to skip to the end of today's lesson and come back to this material later.

  • + Share This
  • 🔖 Save To Your Account