Programas en C#

Wednesday, October 18, 2006

4. Programa para pasar de decimal a hexadecimal. Con control de excepciones.
using System;
using System.Collections.Generic;
using System.Text;
namespace pasarhex
{
class Program
{
static void Main(string[] args)
{ try
{
string cad;
int n;
Console.Write("Introduce un número decimal= ");
cad = Console.ReadLine();
n = Convert.ToInt32(cad);
Console.WriteLine(" {0} equivale en hexadecimal a {1:x}", n, n);
}
catch (Exception){
Console.WriteLine("Dato erróneo");
}
}
}
}






0 Comments:

Post a Comment

<< Home