c# - Calculate days remaining to a birthday? -


I have a date time with a person's birthday, I have this object on the person's year, month and birthday , Created in the following manner:

  datetime date = new date time (year, month, day);  

I would like to know how many days will be left before this person's next birthday. What is the best way to do this in C # (I'm new in language)?

  // is the birthdate date time in which the date of birthdays is date = date time. today; Date Time Next = New Date Time (Today's Year, Birthday Birthday, Birthday.); If (Next & lt; today) Next = Next Add Year (1); Int numdays = (next - today). day;  

This trivial algorithm fails if birthday is February 29. This is optional (which is basically similar to the answer given by Apple Nielsen:

  Date Time Today = Date Time Today Today Date Time Next Birthday Added Year (Today Year Year Birthday Year); If Next (Lieutenant; Today) Next = Next Add Add Year (1); Int numbers = (Next - Today). Day;  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -