📄 program.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
namespace Example8_6
{
class Program
{
static void Main(string[] args)
{
//声明两个Student结构类型的变量
Student myStudent1;
Student myStudent2;
//对两个结构类型的变量进行初始化
myStudent1 = new Student(1, "Li", "第一小学");
myStudent2 = new Student(2, "Wang", "第二中学");
//调用其GotoSchool方法
myStudent1.GotoSchool();
myStudent2.GotoSchool();
Console.ReadLine();
}
}
/// <summary>
/// Student结构
/// </summary>
public struct Student
{
public int id;
public string name;
public string school;
/// <summary>
/// Student结构的构造函数
/// </summary>
/// <param name="m_id">ID</param>
/// <param name="m_name">Name</param>
/// <param name="m_school">School</param>
public Student(int m_id, string m_name, string m_school)
{
id = m_id;
name = m_name;
school = m_school;
}
/// <summary>
/// GotoSchool方法
/// </summary>
public void GotoSchool()
{
Console.WriteLine("{0}去上学了!", name);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -