No suitable method found was found to override. Why does VS keep telling me this error?
这是我的密码…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Computer_Science_Student { class CompSciStudent : Student { private double MATH_HOURS = 20; private double CS_HOURS = 40; private double GEN_HOURS = 60; private string _academicTrack; public CompSciStudent(string name, string id, string track) : base(name, id) { _academicTrack = track; } public string AcademdicTrack { get { return _academicTrack; } set { _academicTrack = value; } } public override double RequiredHours { get { return MATH_HOURS + CS_HOURS + GEN_HOURS; } } } } |
我不太熟悉覆盖,所以我不确定这里出了什么问题。有什么想法吗?实际的错误发生在第28行(公共覆盖需要两个小时),但我感觉这与程序的第16行有关。
编辑:
学生班:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Computer_Science_Student { abstract class Student { private string _name; private string _id; public Student(string name, string id) { _name = name; _id = id; } public string Name { get { return _name; } set { _name = value; } } public string ID { get { return _id; } set { _id = value; } } public abstract double RequiredhOurs { get; } } } |
现在程序仍在说没有合适的重写方法,"compsciestudent"不实现继承的抽象成员student.requiredhours.get"computer science student"。
你的密码有错。您不能覆盖所需时间的原因是,在您的学生课堂上,它是由