题目内容

阅读程序,写出程序运行结果。using System;delegate void MyDel(string value);class Program{void Print1(string value){Console.WriteLine("方法1:{0}", value);}void Print2(string value){Console.WriteLine("方法2:{0}", value);}void Print3(string value){Console.WriteLine("方法3:{0}", value);}/// /// 执行委托方法/// /// 委托类型参数/// 委托内方法的参数void PrintFun(MyDel d, string value){d(value);}static void Main(string[] args){Program p = new Program();MyDel del1, del2, del3;//声明委托变量//赋值del1 = p.Print1;del2 = p.Print2;//组合委托del3 = del1 + del2;//给委托赋新值del1 = p.Print2;//给委托添加方法del1 += p.Print3;//从委托移除方法del1 -= p.Print2;p.PrintFun(del1, "已运行");//调用Console.WriteLine("\n运行组合委托");p.PrintFun(del3, "已运行");Console.ReadKey();}}

查看答案
更多问题

阅读程序,写出程序运行结果: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的关联值是()

答案查题题库