Billpeng Space

技术源自生活
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2011年11月2日

摘要: 在C#中用Delegate和接口的回调都能实现外部方法的委托调用,它们有什么区别呢?Delegate可以用+=或-=快速的绑定或解绑多个方法。而接口实现起来则显得更麻烦。如果Delegate只绑定一个事件,接口中也只定义了一个方法则两者是等价的。 Delegate例子: namespaceTest{classProgram{staticvoidMain(string[]args){CarDelegatecar=newCarDelegate();car.ColorEvent+=newCarDelegate.ColorHandler(ColorMethod1);car.ColorEvent+=n. 阅读全文

posted @ 2011-11-02 10:15 billpeng 阅读(403) 评论(0) 推荐(0) 编辑