新手,我的代码有问题。在此代码返回一个字符串数组(学生姓名)之前,但我需要添加学生 ID,而不需要我重新编码整个方法。有人可以帮我怎么做吗?基本上我需要包括基于学生姓名的学生证。
TIA。
public Student[] GetAllStudents(string subject)
{
Student[] students = cache.GetAllStudents(subject);
if (students == null)
{
Subjects group = RetrieveSubjects(subject);
if (group != null)
{
students = group.Students.Select(r => r.StudentName).ToArray();
// I need to include also the Student ID based on the Student Name queried above.
}
else
{
students = new string[0];
}
cache.AddAllStudents(subject, students);
}
return students;
}