CSharp examples for System:DateTime Calculate
Calculate Age
using System.Threading.Tasks; using System.Text; using System.Net.Sockets; using System.Net; using System.Linq; using System.Collections.Generic; using System;//from www . j av a2s.c om public class Main{ public static int CalculateAge(DateTime source, DateTime birthday) { int anos = source.Year - birthday.Year; if (source.Month < birthday.Month || (source.Month == birthday.Month && source.Day < birthday.Day)) anos--; return anos; } }