Recursion with Func

Like this:

Func<...> method = null;
method = (...) => {
    return method();
};

Your code produces an error because you’re trying to use the variable before you assign it.
Your lambda expression is compiled before the variable is set (the variable can only be set to a complete expression), so it cannot use the variable.
Setting the variable to null first avoids this issue, because it will already be set when the lambda expression is compiled.

As a more powerful approach, you can use a YCombinator.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)