【发布时间】:2022-04-19 22:01:27
【问题描述】:
Func<...> 可以接受 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);
}
我无法定义一个可以接受ref 输入参数的Func<...>。
【问题讨论】:
-
为什么你认为你需要一个
ref参数?
标签: c#-4.0