//实现一个接口
using System;
public interface ITeacher
{
bool AgreeToTeach();      //注意!无需用public abstract
void Print(string b);     //注意!无需用public abstract
}                         //声明一个接口
public class Professor:ITeacher       //实现接口
{
private int course;
public int Course
{
   set{course=value;}
   get{return course;}
}
public bool AgreeToTeach()   //无需用override
{
   if(Course==1)
     return true;
   else
     return false;
}
public void Print(string a)
{
   Console.WriteLine(this.AgreeToTeach()+a);
}
static void Main()
{
   Professor a=new Professor();
   a.Course=1;
   a.Print("! this is yatasoft");
}
}

相关文章:

  • 2021-07-21
  • 2021-06-19
  • 2021-07-07
  • 2022-12-23
  • 2022-12-23
  • 2021-10-01
  • 2021-06-24
  • 2021-06-17
猜你喜欢
  • 2021-07-18
  • 2021-11-02
  • 2021-10-27
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2021-06-26
相关资源
相似解决方案