Advertisement
halleman19

int.parse

Nov 23rd, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace DemoConsole
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.Title = "Int parse";
  14.  
  15.             string number;
  16.  
  17.             Console.WriteLine("Enter number");
  18.  
  19.             number = Console.ReadLine();
  20.  
  21.             try
  22.             {
  23.                 int i = int.Parse(number);
  24.                 Console.WriteLine("success");
  25.             }
  26.             catch(Exception ex)
  27.             {
  28.                 Console.WriteLine("error");
  29.             }
  30.  
  31.             Console.ReadLine();
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement