📄 program.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
namespace 继承实例
{
/************************
* 程序描述:继承实例。子类student和techer从person继承了id、sex、name三个成员
* 另外还分别定义了自己的成员。
* 创 建 人:ncbcy@eiTarget
* 版 本 号:1.0.0
* 修改记录:0
***********************/
class Program
{
static void Main(string[] args)
{
techer th = new techer(11, "男", "车", "政法系");
student st = new student(21, "男", "赵", 0411);
Console.WriteLine(th.id + "\t" + th.name + "\t" + th.sex + "\t" + th.depart);
Console.WriteLine(st.id + "\t" + st.name + "\t" + st.sex + "\t" + st.classid);
Console.ReadLine();
}
}
class person
{
public int id;
public string sex;
public string name;
}
class techer : person
{
public string depart;
public techer(int id, string sex, string name, string depart)
{
this.id = id;
this.sex = sex;
this.name = name;
this.depart = depart;
}
}
class student : person
{
public int classid;
public student(int id, string sex, string name, int classid)
{
this.id = id;
this.sex = sex;
this.name = name;
this.classid = classid;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -