Created
March 21, 2021 11:46
-
-
Save zHaytam/6f9c7726bd9ab6022ece39506a08985e to your computer and use it in GitHub Desktop.
This file contains 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
Action simpleAction = () => Console.WriteLine("Simple Action"); | |
Action<int> actionWithArg = (i) => Console.WriteLine("Simple Action " + i); | |
Func<Task> taskFunc = () => Task.CompletedTask; | |
Func<int, Task> taskWithArgFunc = (i) => Task.FromResult(i); | |
MulticastDelegate delegate1 = simpleAction; | |
MulticastDelegate delegate2 = actionWithArg; | |
MulticastDelegate delegate3 = taskFunc; | |
MulticastDelegate delegate4 = taskWithArgFunc; | |
Console.WriteLine(delegate1 is Action); // true | |
delegate1.GetInvocationList()[0].DynamicInvoke(); // Simple Action | |
delegate2.GetInvocationList()[0].DynamicInvoke(999); // Simple Action 999 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment