用c#写一段程序

来源:百度知道 编辑:UC知道 时间:2024/06/29 22:41:13
定义一个学生Student类,必须有姓名(Name)、年龄(Age)、学号(StudentID)三个属性,再定义一个显示信息(ShowInfo)方法用来输出该学生的姓名、年龄和学号。

public class Student
{
private string _Name;
private int _Age;
private string _StudentID;

public Student()
{
this._Name = "";
this._Age = "";
this._StudentID = "";
}

public string Name
{
get { return this._Name; }
set { this._Name = value;
}

public int Age
{
get { return this._Age; }
set { this._Age= value;
}

public string StudentID
{
get { return this._StudentID; }
set { this._Age= StudentID;
}

public void ShowStudent()
{
Console.WriteLine("Name:{0}, Age:{1}, StudentID:{3}", this._Name, this._Age, this._StudentID);
}

}

public class Student
{
public Student(string name,int age,int id)