static void Main(string[] args)
 {
     PartTimeEmployee P1 = new PartTimeEmployee();
     P1.name = "Ujjwal";
     P1.lastname = "Vaish";
     P1.printfullname();
     ((Employee)P1).printfullname(); //This is how we access the parent class method - Typecasting
     Console.ReadKey();
 }
Example #2
0
        public static void Main()
        {
            FullTimeEmployee FTE = new FullTimeEmployee();

            FTE.firstName = "Georgi";
            FTE.lastName  = "Ivanov";
            FTE.PrintFullName();

            PartTimeEmployee PTE = new PartTimeEmployee();

            PTE.firstName = "Ivan";
            PTE.lastName  = "Georgiev";
            PTE.PrintFullName();
        }
        static void Main(string[] args)
        {
            FullTimeEmployee fte = new FullTimeEmployee();

            fte.FirstName = "FullTime";
            fte.LastName  = "Employee";
            fte.PrintFullName();

            PartTimeEmployee pte = new PartTimeEmployee();

            //Employee pte = new PartTimeEmployee(); //calls base class method
            pte.FirstName = "PartTime";
            pte.LastName  = "Employee";
            pte.PrintFullName();
            //((Employee)pte).PrintFullName();Way to call base class method

            Console.ReadKey();
        }
Example #4
0
        static void Main(string[] args)
        {
            FullTimeEmployee FTE = new FullTimeEmployee();

            FTE.FirstName = "FullTime";
            FTE.LastName  = "Employee";
            FTE.Email     = "*****@*****.**";
            FTE.PrintFullName();

            Employee PTE = new PartTimeEmployee();

            //PartTimeEmployee PTE = new PartTimeEmployee();
            PTE.FirstName = "PartTime";
            PTE.LastName  = "Employee";
            PTE.Email     = "*****@*****.**";
            //((Employee)PTE).PrintFullName();
            PTE.PrintFullName();

            Console.Read();
        }
Example #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Learning about method hiding");
            Console.WriteLine();
            PartTimeEmployee pte = new PartTimeEmployee();

            pte.PrintName();

            // to execute whateve =r is in the base class, alternatively, create the instance of the class
            // using the options below
            Console.WriteLine();
            Console.WriteLine("Create instance using base class that refers to derrived class" +
                              "Why, because the derivved class has all the functionality of the base class");
            Employee emp = new PartTimeEmployee();

            emp.PrintName();

            //alternative three
            Console.WriteLine();
            ((Employee)pte).PrintName();
        }