bool success = Int32.TryParse(value, out number); if (success) { Console.WriteLine("Converted '{0}' to {1}.", value, number); }