How can i change this code to double.TryParse? Without try/catch.
static double PromptForDouble(string promptMessage)
{
Console.WriteLine(promptMessage);
while (true)
{
try
{
var input = Console.ReadLine(); // input = "12124124"
return double.Parse(input); // 1.234
}
catch
{
Console.WriteLine("Zła wartość");
}
}
}
}
This does it.