public static void Main()
    {
        //----------------------------------------------------------------------------------------------------
        // Here we are creating object of derived class and accessing the property of base and derived class.
        //---------------------------------------------------------------------------------------------------
        FullTimeEmployee FTE = new FullTimeEmployee();

        FTE.FirstName    = "John";
        FTE.LastName     = "Doe";
        FTE.Email        = "*****@*****.**";
        FTE.YearlySalary = 500000;
        FTE.FullName();

        PartTimeEmployee PTE = new PartTimeEmployee();

        PTE.FirstName = "Jimmi";
        PTE.LastName  = "Suyang";
        PTE.Email     = "*****@*****.**";
        PTE.HourlyPay = 10;
        PTE.FullName();

        //----------------------------------------------------------------------------------------------------
        // Note : Here in 'FullTimeEmployee' we cannot access property of 'PartTimeEmployee' as 'HourlyPay'
        // because it is specific to 'FullTimeEmployee' and Vice-Versa
        // Here we able to re-use the member of base class.
        //---------------------------------------------------------------------------------------------------
    }
示例#2
0
文件: Program.cs 项目: suyog06/DotNet
    static void Main()
    {
        FullTimeEmployee FTE = new FullTimeEmployee();

        FTE.Fname = "Suyog";
        FTE.Lname = "Shelar";
        FTE.FullName();

        PartTimeEmployee PTE = new PartTimeEmployee();

        PTE.Fname = "Suyog";
        PTE.Lname = "Shelar";
        PTE.FullName();
    }
示例#3
0
    public static void Main()
    {
        //---------------------------------------------------------------------------------------------------
        // To call patent class method we have sevaral ways as i.e
        //---------------------------------------------------------------------------------------------------
        ((Employee)FTE).FullName();

        Employee EFTE = new FullTimeEmployee();

        EFTE.FirstName = "Sara";
        EFTE.LastName  = "Khan";
        EFTE.FullName();


        //----------------------------------------------------------------------------------------------------
        // Here we are creating object of derived class and accessing the property of base and derived class.
        //---------------------------------------------------------------------------------------------------
        FullTimeEmployee FTE = new FullTimeEmployee();

        FTE.FirstName = "John";
        FTE.LastName  = "Doe";
        FTE.FullName();
    }