Answer the question
In order to leave comments, you need to log in
How to count the number of days until the nearest 25th day (of a month) in C#.NET?
It is necessary to count the number of days until the nearest 25th.
That is, if today is the 20th (of any month), then the program will display the number 5.
If today is the 28th and this month has 30 days, then the program will display the number 27 (2 days before the 30th + 25 days).
Answer the question
In order to leave comments, you need to log in
static int DaysTill25(DateTime dt)
{
return dt.Day <= 25 ?
25 - dt.Day
: 25 + (DateTime.DaysInMonth(dt.Year, dt.Month) - dt.Day);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question