委托
是一种后期绑定的代码支持。并且提供了后期绑定的类型安全,并且支持单播和多播。后期绑定是为同个算法抽离差异的代码,例如排序中比较大小的部分。 同时委托也为事件提供了基础。
委托的使用
//delegate 定义委托类型
//声明委托
//添加委托目标方法
tips.
优先使用内置的委托类型,Action
使用带返回值的委托类型,Func
From here you can search these documents. Enter your search terms below.
Keys | Action |
---|---|
? | Open this help |
n | Next page |
p | Previous page |
s | Search |