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

📄 studentdetails.cs

📁 yongle jpscxsd j cxksk xdkl sna
💻 CS
字号:
using System;

namespace Example_1
{
	///<summary>
	/// 此程序演示单重继承的实现。
	///</summary>

	//基类
	public class Person
	{
		private string _name;
		private uint _age;

		public void GetInfo()
		{
			Console.WriteLine("请输入您的姓名和年龄");
			_name = Console.ReadLine();
			_age = uint.Parse(Console.ReadLine());
		}
		public void DispInfo()
		{
			Console.WriteLine("尊敬的 {0},您的年龄为 {1}", _name, _age);
		}
	}

	//派生类
	public class Student:Person
	{
		private string _school;
		private uint _eng;
		private uint _math;
		private uint _sci;
	
		public void GetMarks()
		{
			Console.WriteLine("请输入学校名称");
			_school = Console.ReadLine();
			Console.WriteLine("请分别输入英语、数学和自然科学的分数。");
			_eng = uint.Parse(Console.ReadLine());
			_math = uint.Parse(Console.ReadLine());
			_sci = uint.Parse(Console.ReadLine());
			Console.WriteLine("所得总分为:{0}",_eng+_math+_sci);
		}
	}

	public class Exercise
	{

		///<summary>
		/// 应用程序的主入口点。
		///</summary>
		[STAThread]
		static void Main(string[] args)
		{
			Student objStudent = new Student();
			objStudent.GetInfo();	//访问基类成员
			objStudent.DispInfo();	//访问基类成员
			objStudent.GetMarks();

		}
	}
}

⌨️ 快捷键说明

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