YTU OJ 3447 C# 问题 D: C#解密出生日期

YTU OJ 3447 C# 问题 D: C#解密出生日期

在这里插入图片描述

using System;

namespace text1
{
    
    
    class Program
    {
    
    
        static void Main(String[] args) 
        {
    
    
            Method(Console.ReadLine());
        }
        static string Method(string str)
        {
    
    
            DateTime now = new DateTime(2019, 12, 5);//设置现在的时间  
            DateTime birthday = DateTime.Parse(str);//出生日期
            DateTime year60 = birthday.AddYears(60);//60岁时的日期
            int time = now.Year - birthday.Year;
            TimeSpan time1 = year60 - now;
            Console.WriteLine(time);
            Console.WriteLine(time1.Days);
            return str;
        }
    }
}

猜你喜欢

转载自blog.csdn.net/henishu/article/details/114986502