Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp8
- {
- class Program
- {
- static void Main(string[] args)
- {
- int number = 0;
- while (true)
- {
- try
- {
- number = int.Parse(Console.ReadLine());
- Console.WriteLine("It is a number.");
- break;
- }
- catch (Exception ex)
- {
- Console.WriteLine("Invalid input!");
- break; // without break it will wait for another number
- // throw; - showing the exception/error
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment