Skip to content

Instantly share code, notes, and snippets.

@svick
Created February 7, 2015 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save svick/2d6ce35f9608fe5e7e7f to your computer and use it in GitHub Desktop.
Save svick/2d6ce35f9608fe5e7e7f to your computer and use it in GitHub Desktop.
Delegate with static member
.assembly ActionTest {}
.assembly extern mscorlib
{
.ver 4:0:0:0
.publickeytoken = (B7 7A 5C 56 19 34 E0 89)
}
.namespace Test
{
.class public auto ansi sealed Action extends [mscorlib]System.MulticastDelegate
{
// copied disassembled code of Action delegate
.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(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() runtime managed
{
}
// Empty
.method private hidebysig static void EmptyAction() cil managed
{
ret
}
.method public hidebysig specialname static class Test.Action get_Empty() cil managed
{
ldnull
ldftn void Test.Action::EmptyAction()
newobj instance void Test.Action::.ctor(object, native int)
ret
}
.property class Test.Action Empty()
{
.get class Test.Action Test.Action::get_Empty()
}
}
}
Test.Action action1 = () => { };
action1();
Test.Action action2 = Test.Action.Empty;
action2();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment