Hi, i was wondering if some1 could help me.. How do i make a try-catch to go off when i type a letter or a character..
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 } } } } Microsoft: http://msdn.microsoft.com/en-us/library/0yd65esw%28VS.80%29.aspx Csharpfriends: http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=128