public void Exam(ExamEventArgs task) { if (ExamEvent2 != null) { ExamEvent2(this, task); } }
private static void Task7() { var group = new List <Student> { new Student { FirstName = "John", LastName = "Miller", BirthDate = new DateTime(1997, 3, 12) }, new Student { FirstName = "Candice", LastName = "Leman", BirthDate = new DateTime(1998, 7, 22) }, new Student { FirstName = "Joey", LastName = "Finch", BirthDate = new DateTime(1996, 11, 30) }, new Student { FirstName = "Nicole", LastName = "Taylor", BirthDate = new DateTime(1996, 5, 10) } }; var teacher = new Teacher(); foreach (var student in group) { teacher.ExamEvent2 += student.Exam; } var eventArgs = new ExamEventArgs { Task = "Task 2 2 2 " }; teacher.Exam(eventArgs); }
public void Exam(object sender, ExamEventArgs e) { Console.WriteLine($"Student {LastName} solved the {e.Task}"); }