using System;namespace INTERFACE
{abstract class Person{public string Name { get; set; }public int Age { get; set; }public virtual void ShowInfo(){Console.WriteLine($"Name: {Name}, Age: {Age}");}}// 接口 IWorkinterface IWork{void GotoCompany();}// 接口 IStudyinterface IStudy{void GotoSchool();}// 接口 ITransportinterface ITransport{void Transport();}// Student 类class Student : Person, IStudy, ITransport{public string School { get; set; }public override void ShowInfo(){Console.WriteLine($"School: {School} Name: {Name}, Age: {Age}");}public void GotoSchool(){Console.WriteLine($"去{School}上学");}public void Transport(){Console.WriteLine("乘地铁去学校");}}class Engineer : Person, IWork, ITransport{public string Company { get; set; }public override void ShowInfo(){Console.WriteLine($"Name: {Name}, Age: {Age}");Console.WriteLine($"Company: {Company}");}public void GotoCompany(){Console.WriteLine($"去{Company}上班");}public void Transport(){Console.WriteLine("开车去公司");}}class Program{static void Main(){Student student = new Student { Name = "Alice", Age = 20, School = "南京工业职业技术大学" };student.ShowInfo();student.Transport();student.GotoSchool();Engineer engineer = new Engineer { Name = "Bob", Age = 30, Company = "华为" };engineer.ShowInfo();engineer.GotoCompany();engineer.Transport();Console.Read();}}
}