class1.cs

来自「C#2005 实例源代码」· CS 代码 · 共 50 行

CS
50
字号
using System;

namespace Example_Destruct
{
	/// <summary>
	/// 学生类
	/// </summary>
	public class Student
	{
		private string strName;		//域
		public	string Name		//属性
		{
			get{return this.strName;}
			set{this.strName=value;}
		}

		/// <summary>
		/// 构造函数,为学生起名
		/// </summary>
		public Student(string _strName)
		{
			this.strName=_strName;
		}

		/// <summary>
		/// 析构函数
		/// </summary>
		~Student()
		{
			Console.WriteLine("Call Destruct Method.");
		}
	}

	/// <summary>
	/// Class1 的摘要说明。
	/// </summary>
	class Class1
	{
		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			Student s=new Student("张三");
			Console.WriteLine(s.Name);
		}
	}
}

⌨️ 快捷键说明

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