Type Casting
Learn how to cast an object to another type.
We'll cover the following...
We'll cover the following...
Introduction
In this lesson, we’ll explore the concept called type casting, where we convert an object of one type to an object of another type.
Consider the following example:
It’s safe to assume that the value of in10Years is 34. But, if we change the type of in10Years to byte, our code fails to compile:
It fails because arithmetic operations on whole numbers return a value of the int type. Because in10Years is now a byte, we can’t ...