if ( (new Func</*out*/ string, bool>( (/*out*/ string uname) => ....
more details : that is a part of login function and I just want that my lambda function to changes login-name user with a out parameter and said me that user logined with it's bool return.
I really understand that I can return the Tuple and then get my string value but I want exactly out parameter for some personal clarity. I better return only string with null if user is not login, just want to know if I can use out parameters inside lambda functions.
And I really get that the code with expressions on the statement places is not so clean But none said me if that is really bad for compiler.
Lambda expressions won't work, but for delegates you should be fine using a statement body:
bool outval = false; // definite assignment
Func<bool> func = () => {
return SomeMethod(out foo);
};
bool returned = func();
// check both outval and returned
For delegates... You will need to define your own:
public delegate bool MyType(out string value);
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