About Delegate and Event

来源:互联网 发布:程序员用win还是mac 编辑:程序博客网 时间:2024/05/15 00:05

Just some information, if it is wrong, please correct me. Thank you

wait...

 

Delegate, is used in c sharp, like the feature on "function pointer" in c++.

One friend tell me that is "delegate" is used to encapsulate functions.

 

How to use it?

We can use as "viariable" to use it.

1, Define it:

blic delegate void name()

2, code the functions that will be encapsulated by delegate.

     they should have same return type and parameters

3, register functions to delegate instance

 

Delegate has big business with "Event".

When an "envet" is happen, we don't know what should be doing.

Then, we can use delegate to encapsulate the functions.

 

 

 

原创粉丝点击