I am new to C# (and OOP). When iI have some code like the following:
class Employee
{
// some code
}
class Manager : Employee
{
//some code
}
Question 1: if iIf I have other code that does this:
Manager mgr = new Manager();
Employee emp = (Employee)mgr;
Here employeeEmployee
is a managerManager
, but when iI cast it like that to an Employee
it means iI am upcasting it?
Question 2:
When iI have several Employee
class objects and some but not all of them are Manager
's, how can iI downcast them where possible?