public class Teacher
{
public string name;
public string title;
public static string department;
public void Show()
{
Console.WriteLine("姓名:{0}\n职称:{1}", name, title);
}
public static void ShowDepartment()
{
Console.WriteLine("所属院系:{0}", department);
}
}
class Program
{
static void Main(string[] args)
{
Console.Write("乖乖输入院系鸭:");
Teacher.department = Console.ReadLine();
Teacher sheep = new Teacher();
Console.Write("乖乖输入老师的名字啦:");
sheep.name = Console.ReadLine(); //非静态成员用 “对象名.” 进行访问
Console.Write("乖乖输入老师职称鸭:");
sheep.title = Console.ReadLine();
Console.WriteLine("第一位老师的信息如下:");
sheep.Show();
Teacher.ShowDepartment(); //静态成员用 “类名.”进行访问
Console.ReadLine();
}
}