本文整理汇总了C#中System.DateTime.GetAge方法的典型用法代码示例。如果您正苦于以下问题:C# DateTime.GetAge方法的具体用法?C# DateTime.GetAge怎么用?C# DateTime.GetAge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DateTime
的用法示例。
在下文中一共展示了DateTime.GetAge方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAgeNowForBirthdayToday
public void GetAgeNowForBirthdayToday()
{
var birthday = new DateTime(1970, 3, 5);
var today = new DateTime(2000, 3, 5);
var age = birthday.GetAge(today);
Assert.Equal(30, age);
}
示例2: GetAgeWithTodaySpecifiedForBirthdayYesterdayPriorMonth
public void GetAgeWithTodaySpecifiedForBirthdayYesterdayPriorMonth()
{
var birthday = new DateTime(1990, 9, 30);
var today = new DateTime(2011, 10, 1);
var age = birthday.GetAge(today);
Assert.Equal(21, age);
}
示例3: GetAgeWithTodaySpecifiedForBirthdayYesterdayPriorYear
public void GetAgeWithTodaySpecifiedForBirthdayYesterdayPriorYear()
{
var today = new DateTime(2020, 12, 31);
var birthday = new DateTime(1994, 1, 1);
var age = birthday.GetAge(today);
Assert.Equal(26, age);
}
示例4: GetAgeWithTodaySpecifiedForBirthdayYesterdaySameMonth
public void GetAgeWithTodaySpecifiedForBirthdayYesterdaySameMonth()
{
var birthday = new DateTime(1968, 3, 5);
var today = new DateTime(2000, 3, 5);
var age = birthday.GetAge(today);
Assert.Equal(32, age);
}
示例5: GetAgeWithTodaySpecifiedForBirthdayTomorrowNextYear
public void GetAgeWithTodaySpecifiedForBirthdayTomorrowNextYear()
{
var today = new DateTime(2011, 1, 1);
var birthday = new DateTime(2000, 12, 31);
var age = birthday.GetAge(today);
Assert.Equal(10, age);
}
示例6: GetAgeWithTodaySpecifiedForBirthdayTomorrowNextMonth
public void GetAgeWithTodaySpecifiedForBirthdayTomorrowNextMonth()
{
var today = new DateTime(2011, 8, 31);
var birthday = new DateTime(2000, 9, 1);
var age = birthday.GetAge(today);
Assert.AreEqual(10, age);
}
示例7: GetAgeWithTodaySpecifiedForBirthdayToday
public void GetAgeWithTodaySpecifiedForBirthdayToday()
{
var birthday = new DateTime(1970, 3, 5);
var today = new DateTime(2000, 3, 5);
var age = birthday.GetAge(today);
Assert.AreEqual(30, age);
}
示例8: GetAgeNowForBirthdayTomorrow
public void GetAgeNowForBirthdayTomorrow()
{
var birthday = new DateTime(1970, 3, 6);
var today = new DateTime(2000, 3, 5);
var age = birthday.GetAge(today);
Assert.AreEqual(29, age);
}
示例9: GetAgeWithTodaySpecifiedForBirthdayTomorrowSameMonth
public void GetAgeWithTodaySpecifiedForBirthdayTomorrowSameMonth()
{
var today = new DateTime(2011, 3, 6);
var birthday = new DateTime(1994, 3, 7);
var age = birthday.GetAge(today);
Assert.Equal(16, age);
}