You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
964 B

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;
}
}
}