using Shentun.Utilities; using System; using System.Collections.Generic; using System.Text; namespace System { public static class ConvertExtensions { public static decimal ToDecimal(this string value) { decimal data = 0.0m; if (value.ToUpper().Contains("E")) { data = Convert.ToDecimal(Decimal.Parse(value.ToString(), System.Globalization.NumberStyles.Float)); } else { data = Convert.ToDecimal(value); } return data; } public static int ToAge(this DateTime birthdate) { DateTime now = DateTime.Now; int age = now.Year - birthdate.Year; if (now.Month < birthdate.Month || (now.Month == birthdate.Month && now.Day < birthdate.Day)) { age--; } return age < 0 ? 0 : age; } } }