}
public string pname //ѧÉúÐÕÃûÊôÐÔ { get { return name; } }
public void Testing(DateTime begintime) ·¨
{ Console.WriteLine(\ѧÉú{0}ÔÚ{1}ʱ¿ªÊ¼´ðÌâ...\ }
public void HandIn()
//ѧÉú½»¾íÒý·¢Íê³É¿¼ÊÔʼþ
//ѧÉú¿ªÊ¼¿¼ÊÔʼþµ÷Óõķ½
{
EndExam(DateTime.Now, this); } }
class Teacher //½ÌʦÀà
{
public event StartExamType StartExam; public void NotifyBeginExam() {
Console.WriteLine(\½ÌʦÐû²¼¿ªÊ¼¿¼ÊÔ\
StartExam(DateTime.Now); //Òý·¢¿ªÊ¼¿¼ÊÔʼþ
}
public void Accept(DateTime accepttime, Student stud)
//ѧÉúÍê³É¿¼ÊÔʼþµ÷Óõķ½·¨
{
Console.WriteLine(\ ѧÉú\Íê³É¿¼ÊÔ,ÀÏʦÊÕ¾í\ } }
class Program {
static void Main(string[] args) {
Teacher t = new Teacher(); Student[] s = new Student[5]; s[0] = new Student(\Õžü\ s[1] = new Student(\³Â»ª\ s[2] = new Student(\ÍõÀö\ s[3] = new Student(\ÐíÔ´\ s[4] = new Student(\Áõ³©\
foreach (Student st in s) {
t.StartExam += new StartExamType(st.Testing);
//¸øÃ¿¸öѧÉú¶©ÔĽÌʦµÄ¿ªÊ¼¿¼ÊÔʼþ st.EndExam += new EndExamType(t.Accept);
//¸ø½Ìʦ¶©ÔÄÿ¸öѧÉúµÄÍê³É´ð¾íʼþ
}
t.NotifyBeginExam(); //½ÌʦÐû²¼¿ªÊ¼¿¼ÊÔ Console.WriteLine(\¾¹ýÒ»¶Îʱ¼ä...\ s[1].HandIn(); //һѧÉúÍê³É´ðÌâ½»¾í Console.WriteLine(\¾¹ýÒ»¶Îʱ¼ä...\ s[2].HandIn(); //һѧÉúÍê³É´ðÌâ½»¾í Console.WriteLine(\¾¹ýÒ»¶Îʱ¼ä...\ s[4].HandIn(); //һѧÉúÍê³É´ðÌâ½»¾í Console.WriteLine(\¾¹ýÒ»¶Îʱ¼ä...\ s[0].HandIn(); //һѧÉúÍê³É´ðÌâ½»¾í Console.WriteLine(\¾¹ýÒ»¶Îʱ¼ä...\ s[3].HandIn(); //һѧÉúÍê³É´ðÌâ½»¾í } }

