Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
根据定义,多播代表的概念解释说它包含对多个函数的引用。但是在日常实践中使用的多播委托或任何真实世界的例子在哪里?
谢谢
一种情况可能如下:
假设我有以下方法:
Execute(MyMultiCastDelegate deleg){ //Do some tasks deleg(); }
我们还假设我想在 Execute 完成时执行三个函数。所以我们声明了一个 MyMultiCastDelegate 的实例,并将三个函数附加到它上面。
如果 Delegates 不是多播,我们将必须声明一个组合这三个函数的函数,然后将其传递给 Execute 函数。