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