Trouble with Inheritance c# [closed]

Remove the getter and setter of your private campusName and rename your public campusName to CampusName.

Add following code in your Campus class

public override string ToString()
{
  return CampusName() + "\n is located at " + ShowAddress() + "\n it has " + Departments();
}

You should write a base School class

public class School
{
  private string schoolName;
  private string address;

  public string SchoolName
  {
     get
     {
       return schoolName;
     }
     set
     {
       schoolName = value;
     }
  }

  // same game with address
}

After that you only have to inherit ….

public Campus : School
{
   // override or add methods 
}

Browse More Popular Posts

Leave a Comment