实现一个Student(学生)类,要求在类中设置:m_Name, m_IdNo,m_Score三个成员变量分别表示学生的姓名, 学号, 成绩,设置m_SetInfo函数对这三个成员变量赋值,设置m_DisplayInfo函数显示学生的姓名, 学号, 成绩。在main函数中构造一个Student类的对象,调用成员函数输入学生的姓名,学号,成绩,并显示这些信息。
C#?
using System;
namespace ConsoleApp2
{
class Student
{
public string m_Name { get; set; }
public string m_IdNo { get; set; }
public int m_Score { get; set; }
public void m_SetInfo(string m_Name, string m_IdNo, int m_Score)
{
this.m_Name = m_Name;
this.m_IdNo = m_IdNo;
this.m_Score = m_Score;
}
public void m_DisplayInfo()
{
Console.WriteLine($"姓名:{m_Name}\t学号:{m_IdNo}\t成绩:{m_Score}");
}
}
class Program
{
static void Main(string[] args)
{
var stu = new Student();
stu.m_SetInfo("张三", "001", 90);
stu.m_DisplayInfo();
Console.ReadKey();
}
}
}