如何实现将由student类实现的接口类 [英] How to implement an interface class that will be implemented by student class
本文介绍了如何实现将由student类实现的接口类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个名为IStudentGrade的接口类,它获取学生姓名并计算学生成绩。我还创建了一个继承Person类的Student类,并实现了接口IStudentGrade类。我将如何从学生班实施IStudentGrade课程?
我尝试过的方法:
I created an interface class called IStudentGrade that gets the student name and calculate the students grade. I also created a Student class that inherits Person class and implements the interface IStudentGrade class. How will I Implement IStudentGrade class from Student Class?
What I have tried:
namespace sample3
{
interface IStudentGrade
{
string StudentName();
int StudentGrade();
}
}
namespace sample3
{
public class Student : Person, IStudentGrade
{
public Student(string FirstName, string LastName, string Gender)
: base(FirstName, LastName, Gender)
{
Console.WriteLine(FirstName, LastName, Gender);
}
}
}
推荐答案
非常简单方式...在Visual Studio中,Student类上的接口IStudentGrade将在其下面有一条波浪线。右键单击,选择重构,然后选择实现接口。
手动,与界面相同但带有正文(功能代码)。
The very easy way... In Visual Studio, the interface IStudentGrade on the Student class will name will have a squiggly line under it. Right-click, select refactor, then Implement Interface.
Manually, same as the interface but with a body (functional code).
这篇关于如何实现将由student类实现的接口类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文