C#获取日期的星期名称

2018-08-17 09:31:11来源:博客园 阅读 ()

新老客户大回馈,云服务器低至5折

 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),

 

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:NoSql浅谈

下一篇:第二节:框架前期准备篇之AutoFac常见用法总结