ARTICLE AD BOX
Use decimal.TryParse() instead of Convert.ToDecimal(), it'll return false on a bad input
decimal valor; while (true) { Console.Write("Enter a number: "); if (decimal.TryParse(Console.ReadLine(), out valor)) break; Console.WriteLine("Invalid input. Please enter a number."); }New contributor
user32581585 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Sign up to request clarification or add additional context in comments.
Explore related questions
See similar questions with these tags.
