C#窗体中怎么样把获取的系统当前 星期数 转换成汉字!!!
//为获取当前系统的星期lblxing.Text=DateTime.Now.DayOfWeek.ToString();即DateTime.Now.DayOfWeek.To...
//为获取当前系统的星期
lblxing.Text = DateTime.Now.DayOfWeek.ToString();
即DateTime.Now.DayOfWeek.ToString();返回的值变成汉字显示!!! 在不使用if判断的情况下!!! 展开
lblxing.Text = DateTime.Now.DayOfWeek.ToString();
即DateTime.Now.DayOfWeek.ToString();返回的值变成汉字显示!!! 在不使用if判断的情况下!!! 展开
3个回答
展开全部
public static string dt;
public static string week;
protected void Page_Load(object sender, EventArgs e)
{
//获取当前日期是星期几
dt = DateTime.Today.DayOfWeek.ToString();
//根据取得的星期英文单词返回汉字
switch (dt)
{
case "Monday":
week = "星期一";
break;
case "Tuesday":
week = "星期二";
break;
case "Wednesday":
week = "星期三";
break;
case "Thursday":
week = "星期四";
break;
case "Friday":
week = "星期五";
break;
case "Saturday":
week = "星期六";
break;
case "Sunday":
week = "星期日";
break;
}
//利用TextBox文本框显示当前日为星期几
this.lblTest1.Text = week;
}
public static string week;
protected void Page_Load(object sender, EventArgs e)
{
//获取当前日期是星期几
dt = DateTime.Today.DayOfWeek.ToString();
//根据取得的星期英文单词返回汉字
switch (dt)
{
case "Monday":
week = "星期一";
break;
case "Tuesday":
week = "星期二";
break;
case "Wednesday":
week = "星期三";
break;
case "Thursday":
week = "星期四";
break;
case "Friday":
week = "星期五";
break;
case "Saturday":
week = "星期六";
break;
case "Sunday":
week = "星期日";
break;
}
//利用TextBox文本框显示当前日为星期几
this.lblTest1.Text = week;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你可以这样写:DateTime.Now.ToString("dddd")
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询