新文章 网摘 文章 随笔 日记

关于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);
 
posted @ 2022-11-08 08:17  岭南春  阅读(23)  评论(0)    收藏  举报