📄 class1.cs
字号:
using System;
namespace Example_GetAndSet
{
/// <summary>
/// 学生类
/// </summary>
public class Student
{
private int nAge; //私有域
public int Age //属性,用户控制对域的访问
{
get
{
return this.nAge;
}
set
{
if(value!=this.nAge)
this.nAge=value;
}
}
/// <summary>
/// 主函数
/// </summary>
static void Main(string[] args)
{
Student s=new Student();
s.Age=20;
Console.WriteLine(s.Age);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -