当前位置: 首页>>代码示例>>C#>>正文


C# DateTime.GetAge方法代码示例

本文整理汇总了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);
        }
开发者ID:awcolich,项目名称:DamienGKit,代码行数:8,代码来源:DateExtensionsTests.cs

示例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);
        }
开发者ID:awcolich,项目名称:DamienGKit,代码行数:8,代码来源:DateExtensionsTests.cs

示例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);
        }
开发者ID:awcolich,项目名称:DamienGKit,代码行数:8,代码来源:DateExtensionsTests.cs

示例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);
        }
开发者ID:awcolich,项目名称:DamienGKit,代码行数:8,代码来源:DateExtensionsTests.cs

示例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);
        }
开发者ID:awcolich,项目名称:DamienGKit,代码行数:8,代码来源:DateExtensionsTests.cs

示例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);
        }
开发者ID:renangrativol,项目名称:DamienGKit,代码行数:8,代码来源:DateExtensionsTests.cs

示例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);
        }
开发者ID:renangrativol,项目名称:DamienGKit,代码行数:8,代码来源:DateExtensionsTests.cs

示例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);
        }
开发者ID:renangrativol,项目名称:DamienGKit,代码行数:8,代码来源:DateExtensionsTests.cs

示例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);
        }
开发者ID:awcolich,项目名称:DamienGKit,代码行数:9,代码来源:DateExtensionsTests.cs


注:本文中的System.DateTime.GetAge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。