我们如何通过C#中的main方法访问私有医生方法

时间:2018-08-08 05:34:44

标签: c# .net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace doctor_inheritance
{
    class nurse:doctor
    {
        private void ret()
        {
            Console.WriteLine("hello");
            records();
        }
    }
    class doctor
    {
        //this is the secret message applied only to the doctors
        int name, specialization;
        private void records()
        {
            Console.WriteLine("these are the records maintained by doctors which cannot be accessed by others");
        }
    }
    class patient:doctor
    {
       public void patients()
        {
          //  doctor d = new doctor();
            records();
            Console.WriteLine("PATIENTS ");
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            patient p = new patient();
              doctor d = new doctor();
            d.records();
            // p.records();
            p.patients();
            Console.ReadLine();
    }

    }
}

在此部分代码中,我为医生做了单独的课程,病人可以访问医生的信息,但是当我尝试编译代码时,如果显示错误,则病人无法访问医生的信息,请帮助我解决错误

0 个答案:

没有答案