欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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#获取日期的星期名称实例代码,希望对大家有所帮助

上一篇:

下一篇: