using System;
namespace ConsoleApplication1
{
class Class1
{
private static int calcIdade(DateTime dNasc)
{
int idade = DateTime.Now.Year - dNasc.Year;
if (DateTime.Now.Month < dNasc.Month ||
(DateTime.Now.Month == dNasc.Month &&
DateTime.Now.Day < dNasc.Day))
idade--;
return idade;
}
[STAThread]
static void Main(string[] args)
{
DateTime data = new DateTime(1964,12,15);
Console.WriteLine("Idade: " + calcIdade(data) + " anos");
Console.ReadLine();
}
}
}
Função C# - Calcular idade de uma pessoa
Procurar neste site . . .
Tempo
Categoria
- .net (22)
- Access (1)
- Ajax (1)
- C# (1)
- Componentes (1)
- Delphi (5)
- Eventos (1)
- Firebird (1)
- Firewall (1)
- Handheld Basic (2)
- hb++ (2)
- Internet Explorer (1)
- Java (2)
- Linux (3)
- Livros (3)
- Microsoft (1)
- Mono (1)
- Navegadores (1)
- NHibernate (2)
- Palm (2)
- PHP (3)
- Por dentro (5)
- Rave (1)
- Redes (1)
- Ruby (6)
- Segurança (1)
- SQL Server (1)
- Tecnologia (2)
- Turbo Delphi (3)
- Utilidade Publica (1)
- Web (2)
- Windows (6)
- Windows Server 2003 (1)
- XML (1)