⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class1.cs

📁 C#2005 实例源代码
💻 CS
字号:
using System;

namespace Example_base
{
	/// <summary>
	/// 学生类
	/// </summary>
	public class Student
	{
		//属性		
		public string strName;	//姓名
		public int nAge;		//年龄

		/// <summary>
		/// 获取学生所有信息
		/// </summary>
		public void GetAllInfo()
		{
			Console.WriteLine("Name:	"+this.strName);
			Console.WriteLine("Age:	"+this.nAge);
		}
	}

	/// <summary>
	/// 大学生类
	/// </summary>
	public class CollegeStudent : Student
	{
		public string strInstitute;	//所在系

		/// <summary>
		/// 获取大学生所有信息
		/// </summary>
		public void GetAllInfo()
		{
			base.GetAllInfo();
			Console.WriteLine("Institute:	"+this.strInstitute);
		}
	}

	/// <summary>
	/// Main函数类
	/// </summary>
	class Class1
	{
		static void Main(string[] args)
		{		
			Student s=new Student();
			s.strName="张三";
			s.nAge=20;
			s.GetAllInfo();

			CollegeStudent cs=new CollegeStudent();
			cs.strName="李四";
			cs.nAge=24;
			cs.strInstitute="计算机学院";
			cs.GetAllInfo();

		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -