static void Main(string[] args) { StudentBO studentBusinessObject = new StudentBO(); //输出所有的学生 foreach (var student1 in studentBusinessObject.getAllStudents()) { Console.WriteLine("Student: [RollNo : " + student1.getRollNo() + ", Name : " + student1.getName() + " ]"); } //更新学生 StudentVO student = studentBusinessObject.getAllStudents().ElementAt(0); student.setName("Michael"); studentBusinessObject.updateStudent(student); //获取学生 studentBusinessObject.getStudent(0); Console.WriteLine("Student: [RollNo : " + student.getRollNo() + ", Name : " + student.getName() + " ]"); Console.ReadKey(); }
public void updateStudent(StudentVO student) { students.ElementAt(student.getRollNo()).setName(student.getName()); Console.WriteLine("Student: Roll No " + student.getRollNo() + ", updated in the database"); }
public static void Main(string[] args) { StudentBO studentBusinessObject = new StudentBO(); //print all students foreach (StudentVO studentItem in studentBusinessObject.getAllStudents()) { Console.WriteLine("Student: [RollNo : " + studentItem.getRollNo() + ", Name : " + studentItem.getName() + " ]"); } //update student StudentVO student = studentBusinessObject.getAllStudents()[0]; student.setName("Michael"); studentBusinessObject.updateStudent(student); //get the student student = studentBusinessObject.getStudent(0); Console.WriteLine("Student: [RollNo : " + student.getRollNo() + ", Name : " + student.getName() + " ]"); }