📄 class1.cs
字号:
using System;
namespace Example_DeclareMethod
{
/// <summary>
/// 学生类
/// </summary>
public class Student
{
//属性
public string strName; //公有属性
private int nAge; //私有属性
//方法...
public void SetAge(int _nAge)
{
this.nAge=_nAge;
}
public int GetAge()
{
return this.nAge;
}
}
/// <summary>
/// Main函数类
/// </summary>
class Class1
{
static void Main(string[] args)
{
Student s=new Student();
s.SetAge(20); //赋值年龄
Console.WriteLine(s.GetAge()); //获取年龄
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -