Exemplo n.º 1
0
        public static void ShowMsg(Object sender, Heater.BoiledEventArgs e)
        {                                                                                    //静态方法
            Heater heater = (Heater)sender;                                                  //这里是不是很熟悉呢?

            Trace.WriteLine(string.Format("Display:{0} - {1}: ", heater.area, heater.type)); //访问 sender 中的公共字段
            Trace.WriteLine(string.Format("Display:水快开了,当前温度:{0}度。", e.temperature));
        }
Exemplo n.º 2
0
        // 发出语音警报
        public void MakeAlert(Object sender, Heater.BoiledEventArgs e)
        {
            Heater heater = (Heater)sender;                                                //这里是不是很熟悉呢?

            Trace.WriteLine(string.Format("Alarm:{0} - {1}: ", heater.area, heater.type)); //访问 sender 中的公共字段
            Trace.WriteLine(string.Format("Alarm:嘀嘀嘀,水已经 {0} 度了。", e.temperature));
        }