CSharp examples for System:DateTime Calculate
Age Calculator which returns byte value
using System;/*from w w w .java 2s.c om*/ public class Main{ public static byte? Age(DateTime? date) { if (!date.HasValue) { return null; } var birthDate = date.Value; var now = DateTime.Now; var age = now.Year - birthDate.Year; if (now.Month < birthDate.Month || (now.Month == birthDate.Month && now.Day < birthDate.Day)) { age--; } return (byte)age; } }