public class Foo
{
public void DoFoo()
{
int x;
var coll = TheFunc("bar", out x);
}
public Func<string, int, ICollection<string>> TheFunc { get; set; }
}
Error: "Argument 2 should not be passed with the 'out' keyword."
public class Foo
{
public void DoFoo()
{
int x;
var coll = TheFunc("bar", out x);
}
public Func<string, out int, ICollection<string>> TheFunc { get; set; }
}
Error: "Invalid variance modifier. Only interface and delegate type parameters can be specified as variant."
How do I get an out parameter in this function?
Define a delegate type:
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; }
}
You need to make your own delegate:
delegate ICollection<string> MyFunc(string x, out int y);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With