C# 如何通过c中的main方法访问private doctor方法#
在代码的这一部分中,我为博士做了单独的课程,患者,医生可以访问医生信息,但患者无法访问医生信息,当我尝试编译代码时,代码显示错误,请帮助我解决错误您需要了解这些错误以及它们是如何工作的。护士和患者不是医生类型。我怀疑有更直观的方法来构建您的层次结构。将错误消息、行和堆栈跟踪添加到问题。请更改问题的标题,医生是您具体类的术语您甚至可以访问医生对象上的私有C# 如何通过c中的main方法访问private doctor方法#,c#,.net,C#,.net,在代码的这一部分中,我为博士做了单独的课程,患者,医生可以访问医生信息,但患者无法访问医生信息,当我尝试编译代码时,代码显示错误,请帮助我解决错误您需要了解这些错误以及它们是如何工作的。护士和患者不是医生类型。我怀疑有更直观的方法来构建您的层次结构。将错误消息、行和堆栈跟踪添加到问题。请更改问题的标题,医生是您具体类的术语您甚至可以访问医生对象上的私有记录方法吗?另一方面,非患者和医生是两个不同的实体。我的建议是重新考虑设计,不要将医生类继承到病人类。 using System; using S
记录方法吗?另一方面,非患者和医生是两个不同的实体。我的建议是重新考虑设计,不要将医生类继承到病人类。
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();
}
}
}