Skill Tree Activated

The quest to become an indie game developer

C#CodingTraining

Codeasy.net C# Beginner – Type Conversion

Day 48 #100DaysOfCode

Implicit data conversion happens when you change from a lower data type to a higher data type, such as converting from byte to int to double. When you change to a higher bitrate form of data the conversion can happen automatically as it is understood the data will be larger and can accommodate whatever you are converting from. The same is not true in reverse.

example data types that may be implicitly converted upwards

To convert data to a lower form of bitrate, such as from double to int, you must declare your intent to do so because there will be data loss after the conversion. This is known as an explicit data conversion, or casting.

explicit data conversion from int to double
in order to return a number in decimal form

Casting allows you to drop data you don’t need to reduce the amount of data stored in a variable by changing its type. Casting also allows you to ensure you are working with data in exactly the manner you need to.

using casting to ensure an accurate answer

Leave a Reply

Your email address will not be published. Required fields are marked *