By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,667 Members | 1,678 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,667 IT Pros & Developers. It's quick & easy.

enum 'expansion' / 'extention'

P: n/a
Not sure what to call this, but I have a series of User Controls that
display the days of the week. Usually using a set of radio buttons. Works
very well.

I display the user controls in a form and typically allow the user to select
only a single day within a single week. There are at times, up to 8 weeks
displayed, but the user is allowed only one day to be selected across all
controls. As the use clicks on a radio button, all other buttons on all
other user controls are cleared. I am doing this by fireing an event from
the control to the windows form. Again, works very well.

I use the 'System.DayOfWeek' enumeration to get and set the value of the
control. I even use this enumeration in the even on the control that is
fired when the user changed the selection. Again works very well.

Now, I would like to add a state that has no selection on the control. I am
currently doing this with an additional Boolean flag, but is there any way
that I can in effect add another value to System.DayOfWeek. This would be
really helpful as I could continue to pass this value around my application
without worrying about conversion.

Or, is this a possible use for nullable types in 2.0?

-Andrew
Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Andrew,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to add a new null value to the
System.DayOfWeek enumeration. If there is any misunderstanding, please feel
free to let me know.

Currently, we cannot add an enum to the DayOfWeek enumeration. So I think
the best workaround is to add a flag which indicates if the object has
value.

However, in .NET framework 2.0, we'll have nullable types for value types.
You can just declare an object as follows:

Nullable<System.DayOfWeek> a = null;
or
Nullable<System.DayOfWeek> a = DayOfWeek.Sunday;

We can use a.HasValue to check if it is a null value.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #2

P: n/a
thanks, pretty much what I thought all the way around.

-Andrew

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:Zl**************@TK2MSFTNGXA02.phx.gbl...
Hi Andrew,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to add a new null value to
the
System.DayOfWeek enumeration. If there is any misunderstanding, please
feel
free to let me know.

Currently, we cannot add an enum to the DayOfWeek enumeration. So I think
the best workaround is to add a flag which indicates if the object has
value.

However, in .NET framework 2.0, we'll have nullable types for value types.
You can just declare an object as follows:

Nullable<System.DayOfWeek> a = null;
or
Nullable<System.DayOfWeek> a = DayOfWeek.Sunday;

We can use a.HasValue to check if it is a null value.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #3

P: n/a
You're welcome, Andrew.

Thanks for sharing your experience with all the people here. If you have
any questions, please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.