Advertisement
VelizarAvramov

12. Number Checker

Jul 17th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1. Write a program, which reads an input from the console and prints "It is a number." if it’s a number. If it is not write "Invalid input!"
  2. using System;
  3.  
  4. namespace _12._Number_Checker
  5. {
  6.     class NumberChek
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             //var input = Console.ReadLine();
  11.  
  12.             try
  13.             {
  14.                 var input = int.Parse(Console.ReadLine());
  15.                 Console.WriteLine("It is a number.");
  16.             }
  17.             catch (Exception)
  18.             {
  19.                 Console.WriteLine("Invalid input!");              
  20.             }
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement