在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
参考:
C# 中的委托和事件(续)
我的总结如下: 1)实例:
namespace Test { public delegate void ProcessEventHandler(string name); public class MyTest { public event ProcessEventHandler myProcessEvent; } } 2) IL代码:
.namespace Test { .class public auto ansi beforefieldinit MyTest extends [mscorlib]System.Object { .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { } .field private class Test.ProcessEventHandler myProcessEvent .event Test.ProcessEventHandler myProcessEvent { .addon instance void Test.MyTest::add_myProcessEvent(class Test.ProcessEventHandler) .removeon instance void Test.MyTest::remove_myProcessEvent(class Test.ProcessEventHandler) } } .class public auto ansi sealed ProcessEventHandler extends [mscorlib]System.MulticastDelegate { .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed { } .method public hidebysig newslot virtual instance class [mscorlib]System.IAsyncResult BeginInvoke(string name, class [mscorlib]System.AsyncCallback callback, object 'object') runtime managed { } .method public hidebysig newslot virtual instance void EndInvoke(class [mscorlib]System.IAsyncResult result) runtime managed { } .method public hidebysig newslot virtual instance void Invoke(string name) runtime managed { } } }
完! |
请发表评论