关于delegate的疑问。

seacloud 2003-07-31 04:05:41
各位,既然有了interface,C#干吗还要引入delegate啊,难道就为了
他的event机制吗?还是有什么其它的意思?
...全文
29 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
jennyq_zq 2003-07-31
  • 打赏
  • 举报
回复
The delegate tutorial in MSDN mentions the difference:

delegate is useful when single function is used, or several implemetations of one method specification are used. Those functions are parallel.

Interface is mostly a set of methods specification. Those functions might have relationship between each other and the caller is likely to cast interface to or from other objects, interfaces. And also Interface can inherit another Interface.

I think they are two levels of abstraction: function, class.

The Observer pattern should be based on Interface, it is almost impossible to use delegate to implement Director, which has to describe the complex communication between colleagues.
qimini 2003-07-31
  • 打赏
  • 举报
回复
實現設計模式的Observer模式

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧