By now, we know that Solidity is a statically typed language, where variables are defined with specific data types at compile time. The data type cannot be changed for the lifetime of the variable. It means it can only store values that are legal for a data type. For example, uint8 can store values from 0 to 255. It cannot store negative values or values greater than 255. Take a look at the following code to better understand this:
However, there are times when these conversions are required to copy a value into a variable of one type to another, and these are called type conversions. Solidity provides rules for type conversions.
In Solidity, we can perform various kinds of conversion and we will cover these in the following sections.