using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/*
* 委托与事件练习
*
* 表、响铃、按钮
*
* 表时间从0开始,走到6就要响铃
* 响铃后输入n按回车,模拟按掉闹铃。
* 参考资料:http://www.tracefact.net/CSharp-Programming/Delegates-and-Events-in-CSharp.aspx
*
*/
namespace EventDelegateTest
{
class Alarm //特指 响铃
{
public void Belling(object sender, Watch.ReachTimeEventArgs e)
{
Watch w = (Watch)sender;
Console.WriteLine("###w.time= " + w.Time + " w.place= " + w.Place + " dididi, 6 dian la , hayaku okii desu!!");
}
}
class AlarmButton//关闭响铃的按钮
{
public void Press(object sender, Watch.ReachTimeEventArgs e)
{
Watch w = (Watch)sender;
string str = "";
while (str != "n")
{
str = Console.ReadLine();
C# 委托和事件 练习
最新推荐文章于 2022-05-11 15:23:26 发布