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

📄 constructorex.cs

📁 北大青鸟内部资料
💻 CS
字号:
using System;

namespace Example_3
{

	///<summary>
	/// 此程序演示基类构造函数的初始化过程
	///</summary>


	public class Person
	{
		public string _name;
		public uint _age;

		//基类提供构造函数以进行初始化
		public Person(string name, uint age)
		{
			this._name = name;
			this._age = age;
			Console.WriteLine(_name);
			Console.WriteLine(_age);
		}
	}
	public class Student:Person
	{
		private uint _id;
	
		//调用 Person 构造函数
		public Student(string name, uint age, uint id):base(name, age)
		{
			this._id = id;
			Console.WriteLine(_id);
		}
	}	
	public class Exercise
	{

		///<summary>
		/// 应用程序的主入口点。
		///</summary>
		[STAThread]
		static void Main(string[] args)
		{
			//构造 Student
			Student objStudent = new Student("XYZ", 45, 001);
		}
	}

}

⌨️ 快捷键说明

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