如何使学生类可序列化?我正在阅读这篇文章,但如果我要在以下场景中实施它,我不知道什么是正确的方法。
public class Student
{
private string _studentNumber;
private string _lastName;
private string _firtName;
private List<Subject> _subjects;
public Student() { }
public string StudentNumber
{
get { return _studentNumber; }
set { _studentNumber = value; }
}
public string LastName
{
get { return _lastName; }
set { _lastName = value; }
}
public string FirstName
{
get { return _firtName; }
set { _firtName = value; }
}
public List<Subject> Subjects
{
get { return _subjects; }
set { _subjects = value; }
}
}
public class Subject
{
private string _subjectCode;
private string _subjectName;
public Subject() { }
public string SubjectCode
{
get { return _subjectCode; }
set { _subjectCode = value; }
}
public string SubjectName
{
get { return _subjectName; }
set { _subjectName = value; }
}
}