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

C#获取日期的星期名称

程序员文章站 2022-10-06 20:14:11
使用方式: ......
 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),