C#获取日期的星期名称实例代码
具体代码如下所示:
privatestringGetWeekName(DayOfWeekweek)
{
stringweekName="";
switch(week)
{
caseDayOfWeek.Friday:
weekName="周五";
break;
caseDayOfWeek.Monday:
weekName="周一";
break;
caseDayOfWeek.Saturday:
weekName="周六";
break;
caseDayOfWeek.Sunday:
weekName="周日";
break;
caseDayOfWeek.Thursday:
weekName="周四";
break;
caseDayOfWeek.Tuesday:
weekName="周二";
break;
caseDayOfWeek.Wednesday:
weekName="周三";
break;
default:
break;
}
returnweekName;
}
使用方式:
GetWeekName(DateTime.Now.DayOfWeek),
总结
以上所述是小编给大家介绍的C#获取日期的星期名称实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对毛票票网站的支持!