Suppose I have two classes:
class Employee
and
class AdvancedEmployee:Employee
I know something like this will not work, since I cannot omit in C #:
var employee = new Employee(); var advanced = employee as AdvancedEmployee;
My question is: how to make downcast efficiently? Actually, I have a constructor in AdvancedEmployee that takes an Employee parameter as a parameter and uses it to enter its values, basically making a clone.
Update
To allow duplication of data, I slightly changed the approach, and now AdvancedEmployee CONTAINS an employee, not himself. Example:
class Employee; class AdvancedEmployee { private employee public AdvancedEmployee(Employee employee){ this.employee = employee } }
c # downcast
Israel Lot
source share