题目内容

阅读程序,写出程序运行结果:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace EventDemo{class Program{static void Main(string[] args){Ring schoolRing = new Ring();Student student1 = new Student("2018级计科1班");Student student2 = new Student("2018级计科2班");//schoolRing.OnBellSound = student1.DoSomething;//schoolRing.OnBellSound += student2.DoSomething;student1.AddRingEvent(schoolRing);student2.AddRingEvent(schoolRing);schoolRing.Jow(1);//第1空schoolRing.Jow(2); //第2空Console.ReadKey();}}class Ring{public delegate void RingEvent(int ringKind);public RingEvent OnBellSound;public void Jow(int ringKind){if (ringKind == 1 || ringKind == 2){Console.WriteLine(ringKind == 1 ? "上课铃响了:" : "下课铃响了:");if (OnBellSound != null){OnBellSound(ringKind);}}else{Console.WriteLine("铃声不正确");}}}class Student{private string className;public Student(string className){this.className = className;}private void DoSomething(int ringKind){if (ringKind == 1){Console.WriteLine(this.className + "的同学们开始上课了");}else{Console.WriteLine(this.className + "的同学们可以下课休息了");}}public void AddRingEvent(Ring ring){ring.OnBellSound += DoSomething;}public void RemoveRingEvent(Ring ring){ring.OnBellSound -= DoSomething;}}}

查看答案
更多问题

类时存储在()的引用类型;结构是存储在()的值类型

所有结构都直接继承自();所有枚举默认都继承于()

阅读程序,确定枚举成员的关联值。enum Color :uint{Red,Green = 3,Blue,Max = Blue}(1)枚举成员Red的关联值是()(2)枚举成员Green的关联值是()(3)枚举成员Blue的关联值是()(4)枚举成员Max的关联值是()

类中声明的属性往往具有get()和()两个函数。

答案查题题库