Created
March 30, 2012 09:29
-
-
Save hatelove/2250325 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//IL,區域變數,先將Delegate宣告成null,用+= | |
internal class Class1 | |
{ | |
public delegate void MyDelegate(); | |
public void MyTest() | |
{ | |
Class1.MyDelegate mydelegate = null; | |
mydelegate = (Class1.MyDelegate)Delegate.Combine(mydelegate, delegate | |
{ | |
Console.WriteLine("test"); | |
} | |
); | |
mydelegate(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//IL,宣告在全域,用+= | |
internal class Class1 | |
{ | |
public delegate void MyDelegate(); | |
private Class1.MyDelegate mydelegate; | |
public void MyTest() | |
{ | |
this.mydelegate = (Class1.MyDelegate)Delegate.Combine(this.mydelegate, delegate | |
{ | |
Console.WriteLine("test"); | |
} | |
); | |
this.mydelegate(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//IL,區域變數 用= | |
internal class Class1 | |
{ | |
public delegate void MyDelegate(); | |
public void MyTest() | |
{ | |
Class1.MyDelegate mydelegate = delegate | |
{ | |
Console.WriteLine("test"); | |
} | |
; | |
mydelegate(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment