c# - Sorting from earliest to latest date -


how loop every month's first date.

public struct stat{ public datetime date; } 

i have list<stat> have date property. want lowest , newest 1 sorting. first element older , last newer one.

i can got first , second order by.

what want 1st date of every month in between of both first (oldest ) , newest.

string ret = "";

    list<datetime> dates = new list<datetime>();      int breaker = datetime.daysinmonth(datetime.now.year, datetime.now.month);      stats = stats.orderby(x => x.date).tolist();     datetime old = stats.first().date;     datetime @new = stats.last().date;      int diffdays = @new.subtract(old).days;      datetime loopd = datetime.now;      (int = 0; < diffdays; = + breaker)     {         loopd = loopd.adddays(-breaker);         dates.add(loopd);         if (loopd < old)             console.writeline("date" + old);     }      (int j = 0; j < dates.count; j++)     {         if (j == 0)         {             datetime ld= dates[0];             stats.selectmany(x => x.date < @new && x.date > dates[j]);         }     } 

you use this:

list<stat> statlist = new list<stat>(); ... var selecteditem = statlist                    .orderby(item => item.date)                    .select(l => l.last()); 

or use orderbydecending() instead


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -