public class Student
{
private string studentId;
private string studentName;
// 屬性可以修改學生編號
public string StudentId
get { return sStudentId; }
set { studentId = value; }
}
// 屬性可以修改學生姓名
public string StudentName
get { return studentName; }
set { studentName = value; }
// 建構函式
public Student()
public Student(string studentId, string studentName)
this.studentId = studentId;
this.studentName = studentName;
// c#種解構函式作用不大,一般不推薦使用
~Student()
public void Show()
Console.WriteLine(string.Format("編號:%s, 姓名:%s", studentId, studentName));
public class Student
{
private string studentId;
private string studentName;
// 屬性可以修改學生編號
public string StudentId
{
get { return sStudentId; }
set { studentId = value; }
}
// 屬性可以修改學生姓名
public string StudentName
{
get { return studentName; }
set { studentName = value; }
}
// 建構函式
public Student()
{
}
public Student(string studentId, string studentName)
{
this.studentId = studentId;
this.studentName = studentName;
}
// c#種解構函式作用不大,一般不推薦使用
~Student()
{
}
public void Show()
{
Console.WriteLine(string.Format("編號:%s, 姓名:%s", studentId, studentName));
}
}