C#委托、類和事件的驗證
題目描述
程序由兩部分組成,如下代碼所示。第一部分定義了委托、類和事件。第二部分進行驗證。?
using System;
namespace HelloWorldApplication
{ public delegate void DelegateRing();public class Bell{ public event DelegateRing Ring;public void OnRing(){ Ring(); } } / 請填寫代碼 / class HelloWorld { static void Main(string[] args) { try{ Teacher teacher = new Teacher(); teacher.Register(new Bell()); Student student = new Student(); student.Register(new Bell()); Console.ReadKey(); } catch(Exception ex) { Console.WriteLine(ex.Message); } } }
}
輸入
無輸入
輸出
驗證事件輸出
樣例輸入
copy
無
樣例輸出
teacher
student
提示
只需要輸出樣例輸出的結果
只需要提交需要填寫的代碼
public class Teacher{public void Register(Bell bell){Console.WriteLine("teacher");} }public class Student{public void Register(Bell bell){Console.WriteLine("student");}}
?