kirililchev3

Number cheker - try-catch

May 17th, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.35 KB | None | 0 0
  1. using System;
  2.  
  3.     class Program
  4.     {
  5.     private static void Main()
  6.     {
  7.         try
  8.         {
  9.             int num = int.Parse(Console.ReadLine());
  10.             Console.WriteLine("It is a number.");
  11.         }
  12.         catch (Exception)
  13.         {
  14.             Console.WriteLine("Invalid input!");
  15.         }
  16.        
  17.        
  18.  
  19.         }
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment