private void button1_Click(object sender, EventArgs e) { for (ListNode <Student> temp = student_list.getHead(); temp != null; temp = temp.next) { if (temp.val.get_rollno() == delStudentBox.Text) { std = temp; } } student_list.delete(std); string studentfile = "student_file.bin"; using (Stream stream = File.Open(studentfile, FileMode.Create)) { var bformatter = new BinaryFormatter(); bformatter.Serialize(stream, student_list); } button1.Hide(); delStudentBox.Hide(); MessageBox.Show("Deleted Successfully"); }
private void button2_Click(object sender, EventArgs e) { for (ListNode <Course> temp = courses.getHead(); temp != null; temp = temp.next) { if (temp.val.get_course_code() == delCourseBox.Text) { crs = temp; } } MessageBox.Show(crs.val.get_course_code()); courses.delete(crs); string serializationFile = "course_file.bin"; using (Stream stream = File.Open(serializationFile, FileMode.Create)) { var bformatter = new BinaryFormatter(); bformatter.Serialize(stream, courses); } button2.Hide(); delCourseBox.Hide(); MessageBox.Show("Deleted Successfully"); }