C#获取日期的星期名称实例代码
程序员文章站
2023-12-17 09:56:34
具体代码如下所示:
private string getweekname(dayofweek week)
{
string weeknam...
具体代码如下所示:
private string getweekname(dayofweek week) { string weekname = ""; switch (week) { case dayofweek.friday: weekname = "周五"; break; case dayofweek.monday: weekname = "周一"; break; case dayofweek.saturday: weekname = "周六"; break; case dayofweek.sunday: weekname = "周日"; break; case dayofweek.thursday: weekname = "周四"; break; case dayofweek.tuesday: weekname = "周二"; break; case dayofweek.wednesday: weekname = "周三"; break; default: break; } return weekname; }
使用方式:
getweekname(datetime.now.dayofweek),
总结
以上所述是小编给大家介绍的c#获取日期的星期名称实例代码,希望对大家有所帮助