473,508 Members | 2,267 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with WeekDay Enum

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
Nov 16 '05 #1
3 12399
You can use:

System.DayOfWeek

Example:

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

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

Lowell


Stuart Shay wrote:
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

Nov 16 '05 #2
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
"Lowell Heddings" <lo****@mindjunction.com> wrote in message
news:uz**************@TK2MSFTNGP11.phx.gbl...
You can use:

System.DayOfWeek

Example:

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

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

Lowell


Stuart Shay wrote:
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


Nov 16 '05 #3
That's way more work than is necessary:

int wday = 0;
DayOfWeek day = (DayOfWeek) wday;
lblWeekDay.Text = day.ToString();

Of course, we could reduce it even further to :

DayOfWeek day = DayOfWeek.Sunday;
lblWeekDay.Text = day.ToString();

--
Truth,
James Curran
[erstwhile VC++ MVP]
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com

"Stuart Shay" <ss***@j51.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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
"Lowell Heddings" <lo****@mindjunction.com> wrote in message
news:uz**************@TK2MSFTNGP11.phx.gbl...
You can use:

System.DayOfWeek

Example:

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

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

Lowell


Stuart Shay wrote:
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

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2013
by: Kd | last post by:
I am currently using a form with Weekdays Mon Tues Wed Thur Fri This is generated by a table that the days are being entered manually I would like to create a form that the days updated...
26
2467
by: Alexander Farber | last post by:
Hi, I have a UNIX-server written in C, which exchanges messages with Java clients. In the message the 1 byte is its length, the 2nd a player number and the 3rd byte is an event id: /* 0....
8
8203
by: SteveK | last post by:
I'm getting the error: "Cannot implicitly convert type 'MovesDBMigrate.MotionNameElementTypes' to 'int'" for this line of code: m_nameElementTableNames = "Tbl_NameCharacters"; Of course if...
2
2151
by: faithict | last post by:
I am still new to C++ programming and I have a project that is going to due pretty soon. Here is my question. Does anyone knows how to check through all the members in enum? For example the...
1
2077
by: robinsand | last post by:
I am a new C++ programmer. I am still having trouble with certain data types and constructors, among other things. I'm not sure if I've used "std::string" properly throughout this program. I need...
3
1783
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i'm trying to say something like the following but tripping up on syntax. Basically, i'm trying to expose an enum that's inside my webusercontrol to my client which is my .aspx page ...
3
1396
by: noellieb | last post by:
I have class project and was asked to design 2 classes. 1 : Class Coin designated by coin type (PENNY, NICKEL, DIME, QUARTER OR DOLLAR) 2: Create Class CoinChanger To allow coin changing : say if...
6
1343
by: BillG | last post by:
I have the following defined. enum DisplayEventType{DISPUTE = 0x0001, ACTION = 0x0002, QUESTION = 0x0004); DisplayEventType dEventType; if(DisputesCheckBox.Checked) dEventType = dEventType...
5
3316
by: Ankit Khare | last post by:
As i read size of enum is sufficient enough to hold any integer value,thus its 4 bytes in my machine. typedef enum{ Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7494
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5050
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.