vb.net – 将DayOfWeek枚举转换为一个重复当天的字符串

前端之家收集整理的这篇文章主要介绍了vb.net – 将DayOfWeek枚举转换为一个重复当天的字符串前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想知道是否有办法直接将DayOfWeek返回的整数转换为表示星期一,星期二等日期的字符串.

示例代码

MessageBox.Show(Date.Today.DayOfWeek)

这将返回6(截至今天).例如,有没有办法将其直接转换为星期六?我真的不关心它真正转化为什么,但我想取消我的Select Case:

Select Case Date.Today.DayOfWeek
     Case 0
         day = "Sunday"
     Case 1
         day = "Monday"
     Case 2
         day = "Tuesday"
     Case 3
         day = "Wednesday"
     Case 4
         day = "Thursday"
     Case 5
         day = "Friday"
     Case 6
         day = "Saturday"
     Case Else
         day = "Apocalypse: we're all boned."
 End Select

谢谢 :)

一种更简单的方法
Dim day As String = Date.Today.DayOfWeek.ToString()

猜你在找的VB相关文章