Func(T)可以接受C#中的引用类型变量.
static void Main()
{
Func<string,int, int> method = Work;
method.BeginInvoke("test",0, Done, method);
// ...
//
}
static int Work(ref string s,int a) { return s.Length; }
static void Done(IAsyncResult cookie)
{
var target = (Func<string, int>)cookie.AsyncState;
int result = target.EndInvoke(cookie);
Console.WriteLine("String length is: " + result);
}
Run Code Online (Sandbox Code Playgroud)
我无法定义一个可以接受ref类型输入参数的func.有人请指教......
c#-4.0 ×1