关于func:C#-如何传递对需要out变量的函数的引用?
定义一个委托类型:
public delegate ICollection<string> FooDelegate(string a, out int b);
public class Foo
{
public void DoFoo()
{
int x;
var coll = TheFunc("bar", out x);
}
public FooDelegate TheFunc { get; set; }
}
您需要创建自己的方法实例:
delegate ICollection<string> MyFunc(string x, out int y);
定义一个委托类型:
|
1
2 3 4 5 6 7 8 9 10 11 12 |
public delegate ICollection<string> FooDelegate(string a, out int b);
public class Foo { public void DoFoo() { int x; var coll = TheFunc("bar", out x); } public FooDelegate TheFunc { get; set; } } |
您需要创建自己的代表:
|
1
|
delegate ICollection<string> MyFunc(string x, out int y);
|
浙公网安备 33010602011771号