Help with WeekDay Enum

  • Thread starter Thread starter Stuart Shay
  • Start date Start date
S

Stuart Shay

Hello All:

I have some old ASP Code where it use the WeekdayName Function

How Can I get the following values in C#

wday = 1; => Sunday
wday = 4; => Wednesday

I see VB.NET has the Microsoft.VisualBasic.DateAndTime.WeekdayName, but not
in C#

Thanks
Stuart
 
You can use:

System.DayOfWeek

Example:

System.DayOfWeek day = 0; // equals System.DayOfWeek.Sunday

MessageBox.Show(day.ToString()); // Outputs "Sunday"

Lowell
 
Lowell:

Thanks Got it too work

int wday = 0;
DayOfWeek day = (DayOfWeek) Enum.Parse(typeof(DayOfWeek), wday.ToString());
lblWeekDay.Text = day.ToString();

Sunday is Displayed as the Label Text.

Best
SPS
 
Back
Top