c# - How to create link in for loop via Datetime -
i want create text(link) every month of year
may, 2013 april, 2013 march, 2013 february, 2013 january, 2013 december, 2012
to have created loop
var start = datetime.now; var end = datetime.now.addyears(20); (datetime time = start; time <= end; time = time.addmonths(1)) { //month , year }
but i'm not sure because not work :(
something like:
datetime enddate = new datetime(2013, 12, 31); list<string> list = new list<string>(); (datetime startdate = new datetime(2013, 1, 1); startdate.month <= enddate.month; startdate = startdate.addmonths(1)) { list.add(startdate.tostring("mmmm, yyyy")); if (startdate.month == enddate.month) break; }
for output:
foreach(string str in list) console.writeline(str);
output be:
january, 2013 february, 2013 march, 2013 april, 2013 may, 2013 june, 2013 july, 2013 august, 2013 september, 2013 october, 2013 november, 2013 december, 2013
Comments
Post a Comment