Effect
The code is as follows:
namespacewebform{ Public Partial classWebForm1:System.Web.UI.Page {protected voidPage_Load (Objectsender, EventArgs e) {Printcalender ( .,Ten); } Public Static voidPrintcalender (intYearintmonth) {formatdate FD=NewFormatDate (year, month); stringCalender =@"day 123456 {0} {0} {0} {0} {0} {0} {0}{0} {0} {0} {0} {0} {0} {0}{0} {0} {0} {0} {0} {0} {0}{0} {0} {0} {0} {0} {0} {0} {0} {0} {0} {0} {0}{0} {0} {0} {0} {0} {0} {0}"; Calender=string. Format (calender, FD). TrimEnd (); HttpContext.Current.Response.Write (calender); } } Public classformatdate:iformattable {intnum; intMax; PublicFormatDate (intYearintmonth) {DateTime dt=NewDateTime (year, month,1); Num= (int) dt. DayOfWeek *-1; Max=Datetime.daysinmonth (year, month); } Public stringToString (stringformat, IFormatProvider formatprovider) { returnnum++ <0|| num > Max?" ": Num. ToString ("xx"); } }}
C # Implementation output month's monthly calendar