You can return the Foo
as the return value of the lambda expression:
Func<Foo> someFunc = o =>
{
return new Foo { A = "A new instance of o?" };
};
Or you can return a Tuple<bool, Foo>
if you really need to return a bool
:
Func<Tuple<bool, Foo>> someFunc = o =>
{
return Tuple.Create(true, new Foo { A = "A new instance of o?" });
};
Or, if you're really really sure you want that, you can declare your own custom Func
-like delegate with an out
parameter:
delegate TResult FuncOut<T, TResult>(out T arg);
FuncOut<Foo, bool> someFunc = (out Foo o) =>
{
o = new Foo { A = "A new instance of o?" };
return true;
};
Foo foo;
var result = someFunc(out foo);
But I wouldn't recommend that.