摘要: 当有很多事件,大多数事件不会实现时,可以使用字典存储事件实例,这也是事件选择器的典型用法。 public delegate void EventHandler1(int i); public delegate void EventHandler2(string s); public class PropertyEvent { Dictionary<string, System.Delegate> eventTable; public PropertyEvent() { eventTable = new D... 阅读全文
posted @ 2012-06-25 22:59 蒹葭白露 阅读(1103) 评论(0) 推荐(0) 编辑
摘要: 在类中实现接口事件 可以在接口中声明事件,然后在类中实现该事件的引用。在为方法订阅事件时,可以订阅接口声明的事件,也可以订阅类中的事件。 class InterfaceEvent { static void Main(string[] args) { Shape s = new Shape(); IDrawingObject ido = s; //为HandlerShapeChanged方法订阅接口中声明的事件 ido.ShapeChanged += ... 阅读全文
posted @ 2012-06-25 19:45 蒹葭白露 阅读(2269) 评论(0) 推荐(0) 编辑