out parameter in while loop #4876
Answered
by
HaloFour
FaustVX
asked this question in
Language Ideas
-
In this method, the public static T Ask<T>(string prompt, TryConvert<T> converter)
{
T output;
do
{
Console.Write(prompt + ":");
} while (!(Console.ReadLine() is string read && converter(read, out output)));
return output;
} It would be nice to have the public static T Ask<T>(string prompt, TryConvert<T> converter)
{
do
{
Console.Write(prompt + ":");
} while (!(Console.ReadLine() is string read && converter(read, out var output)));
return output;
} |
Beta Was this translation helpful? Give feedback.
Answered by
HaloFour
Jun 25, 2021
Replies: 1 comment 1 reply
-
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
FaustVX
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See: https://github.com/dotnet/csharplang/blob/main/meetings/2016/LDM-2016-11-30.md#scope-of-while-condition-expression-variables