After-school homework--datetime application, judge how long after birthday and so on

Source: Internet
Author: User

           try {console.write ("Please enter your birthday in the form of a year-month-day:");                String stra = Console.ReadLine ();                DateTime bir = convert.todatetime (stra);                DateTime tod = Datetime.today; Stra = Bir. ToString ("Mm-dd");//Converts the input birthday to the month-day format string StrB = Tod. ToString ("Mm-dd");//Today month day Bir = DateTime.Parse (stra);//convert birthday string to date tod = DateTime.Parse (str                B); TimeSpan ti = bir-tod;//time interval int j = ti.                Days,k;                    if (J >= 0) {if (j = = 0) Console.WriteLine ("Your birthday today, Happy Birthday!"); else Console.WriteLine ("Your birthday is still there" +j+ "Day");//How long is the birthday} Els e {DateTime tod2 = tod.                    AddYears (1);                    TimeSpan t2 = Tod2-tod; k = T2.                    Days; Bir = Bir.                    AddYears (1); Timespan t3 = Tod2-bir; k = T2. Days-t3.                                    days;//the second method of judging Console.WriteLine ("Your birthday is past, next year's birthday is also" + (K+J) + "Days");//Next birthday, how long } Console.WriteLine ("Your Birthday is in" + Bir. DayOfWeek + "," + "is the first birthday of the year" + Bir.            DayOfYear + "Day");            } catch {Console.WriteLine ("You entered the wrong format!"); } console.readline ();

  

After-school homework--datetime application, judge how long after birthday and so on

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.