public abstract class Person
{
public string Name { get; set; }
public int age { set; get; }
public void SayHello()//普通方法
{
Console.WriteLine("我是" + this.Name + ",我的年龄是" + this.age);
}
public virtual int getAge()//虚方法
{
return this.age;
}
public abstract string getName();
}
public interface IAction
{
void Run();
string Eat(string food);
}
public class Student : Person, IAction
{
public override string getName()
{
return "学生姓名为" + this.Name;
}
public string Eat(string food)
{
return "学生在吃" + food;
}
public void Run()
{
Console.WriteLine("学生在跑");
}
}
原文:https://www.cnblogs.com/zykj/p/14949288.html