[英]What is the difference between using a delegate and using Func<T>/Action<T> in a method signature?
[英]What the difference between using .NET tasks with method and action?
方法:
static void HelloWorld() { Console.WriteLine(“Hello, world!”); }
之間有什么區別
Task t1 = new Task(HelloWorld);
和
Task t2 = new Task(new Action(HelloWorld));
實際上沒有區別。 實際上,在兩種情況下,編譯器都會生成相同的代碼:
Task task2 = new Task(new Action((object) null, __methodptr(HelloWorld)));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.