.........

来源:互联网 发布:腾讯云数据可视化 编辑:程序博客网 时间:2024/05/21 21:45

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication4
{
  
   
        class Person
        {
            private string name;
            private int age;
            public Person(string name, int age)
            {
                this.name = name;
                this.age = age;
            }
            public void PersonDisp()
            {
                Console.WriteLine("姓名:"+name);
                Console.WriteLine("年龄:"+age);
            }
        }
        class Employee : Person
        {
            private string department;
            private float salary;
            public Employee(string department, float salary, string name, int age)
                : base(name, age)
            {
                this.department = department;
                this.salary = salary;
            }
            public new void  PersonDisp()
            {
                base.PersonDisp();
                Console.WriteLine("所在部门是:" + department);
                Console.WriteLine("工资是:" + salary);

            }
            //public void EmployeeDisp()
            //{
            //    Console.WriteLine("所在部门是:"+department);
            //    Console.WriteLine("工资是:"+salary);
            //}

        }
    class Program
    {
        public static void Main()
        {

            //Show(null);

            //Show("");

            //Show(1);
            //Console.Read();
            Employee employee = new Employee("开发部",8000,"李宁",25);
            employee.PersonDisp();
            //employee.EmployeeDisp();
            Console.Read();

        }

        //static void Show(Object o)
        //{

        //    Console.WriteLine("Object");

        //}

        //static void Show(String s)
        //{

        //    Console.WriteLine("String");

        //}

    }
}

原创粉丝点击