How to get last Friday of month(s) using .NET

后端 未结 6 875
[愿得一人]
[愿得一人] 2020-12-07 02:03

I have a function that returns me only the fridays from a range of dates

public static List GetDates(DateTime startDate, int weeks)
{
    int         


        
6条回答
  •  我在风中等你
    2020-12-07 02:45

    You already have the list of Fridays in the given range. Now just query this again like this:

    List lastFridays = (from day in fridays
                                  where day.AddDays(7).Month != day.Month
                                  select day).ToList();
    

    Hope this helps.

提交回复
热议问题