Este programa recibe una fecha en formato DD/MM/AAAA y la convierte en el formato AAAA/MM/DD
Código Fuente
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Consola_Fecha_de_nacimiento
{
class Program
{
static void Main(string[] args)
{
DateTime fecha;
bool x;
string formato;
Console.Write("Introduce una fecha en formato DD/MM/AAAA: ");
x = DateTime.TryParse(Console.ReadLine(), out fecha);
if (x == true)
{
formato = fecha.ToString("yyyy/MM/dd");
Console.WriteLine("{0}",formato);
Console.ReadLine();
}
else
{
Console.WriteLine("Este formato o la fecha estan incorrectos");
Console.ReadLine();
}
}
}
}
No hay comentarios.:
Publicar un comentario