Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!
If you write a letter instead of a number, it'll "jump" to catch and write an Exception.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int number;
try
{
//What you want to try!
Console.Write("Write a number: ");
number = Convert.ToInt32(Console.ReadLine());
}
catch (Exception ex)
{
Console.WriteLine(ex); //Writes Exception
}
}
}
}