class1.cs

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

CS
51
字号
using System;

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

		/// <summary>
		/// 构造函数
		/// </summary>
		public Student(string _strName,int _nAge)
		{
			this.strName=_strName;
			this.nAge=_nAge;
		}

		/// <summary>
		/// 长大_nSpan岁
		/// </summary>
		public void Grow(int _nSpan,out int _nOutCurrentAge)
		{
			this.nAge+=_nSpan;
			_nOutCurrentAge=this.nAge;
		}
	}

	/// <summary>
	/// Class1 的摘要说明。
	/// </summary>
	class Class1
	{
		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			Student s=new Student("张三",20);
			int nCurrentAge;	
			s.Grow(3,out nCurrentAge);
			Console.WriteLine(s.nAge);	//输出23
		}
	}
}

⌨️ 快捷键说明

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