Type Casting and Classes
Learn to apply type casting to classes.
We'll cover the following...
Introduction
In a previous lesson, we touched upon the topic of type casting and saw some examples where we cast primitive types between one another:
byte age = 24;
int ageAsInt = age; // Implicit cast
In this lesson, we’ll discuss type casting in the context of classes. Consider a set of following classes:
Press + to interact
Vehicle.cs
Car.cs
Motorcycle.cs
namespace TypeCasting{public class Vehicle{public string Model { get; internal set; }public decimal Price { get; internal set; }public int NumberOfWheels { get; internal set; }}}
These three classes can be visualized by the following ...
Access this course and 1400+ top-rated courses and projects.