public partial class WeekDay : System.Web.UI.Page
{
public static string TodayOfWeek(DateTime dt)
{
string[] WeekDayCn = new string[] { "日", "一", "二", "三", "四", "五", "六" };
return "今天是星期" + WeekDayCn[(int)dt.DayOfWeek];
}
protected void Page_Load(object sender, EventArgs e)
{
DateTime Dt = DateTime.Now;
Response.Write(TodayOfWeek(Dt));
}
}
输出:
今天是星期一
没有评论:
发表评论