Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

upcasting and downcasting in c#

class Employee
{
    // some code
}
class Manager : Employee
{
    //some code
}
// casting can be done by the following
if (employee is Manager)
{
    Manager m = (Manager)employee;
}
// or with the as operator like this:
Manager m = (employee as Manager);

Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #upcasting #downcasting
ADD COMMENT
Topic
Name
7+7 =