C#判断某日为一个星期的第几天

直接上代码:

 int DayinWeek = 0;
            string week = DateTime.Today.DayOfWeek.ToString();
            #region 获取DayinWeek值
            switch (week)
            {
                case "Monday":
                    DayinWeek = 1;
                    break;
                case "Tuesday":
                    DayinWeek = 2;
                    break;
                case "Wednesday":
                    DayinWeek = 3;
                    break;
                case "Thursday":
                    DayinWeek = 4;
                    break;
                case "Friday":
                    DayinWeek = 5;
                    break;
                case "Saturday":
                    DayinWeek = 6;
                    break;
                case "Sunday":
                    DayinWeek = 7;
                    break;
            }
posted @ 2020-04-20 14:54  码农阿亮  阅读(1520)  评论(2编辑  收藏  举报