可能重复:
如何计算C#中某人的年龄?
我想写一个ASP.NET辅助方法,它返回给定生日的人的年龄.
我尝试过这样的代码:
public static string Age(this HtmlHelper helper, DateTime birthday)
{
return (DateTime.Now - birthday); //??
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用.根据他们的生日计算人的年龄的正确方法是什么?