Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2007

Tip: Looking for answers? Try searching our database.

Assigning Default value to Enum Variable

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lucky - 14 Mar 2007 16:59 GMT
Hi guys,

i was working with Enum and one Question strike, i thought it would be
good idea to ask more experience guys around.

the scenerio is like this :

[System.ComponentModel.DefaultValue(check.None)]
   public enum check
   {
       No,
       None,
       yes,
       why
   }

check ch;

all i want to know is, is it possible to assign default value
(like .net value type has NULL as default value) this way?
and if not this way and u know another way of doing it plz let me
know.

by another way i dont mean like this

check ch=check.None;

i mean it should be like  the way i declared on the top.

i would appriciate all your opinon on this.

thanks,

Lucky
Marc Gravell - 14 Mar 2007 17:05 GMT
Use explicit values to get default(T) behaviour, with the 0 item being
the default.

However, defaults (in [DefaultValue] terms) apply to individual
properties, not type-defs - so you can still specify a default of
"yes", "No" or whatever for each property.

Marc
Herfried K. Wagner [MVP] - 14 Mar 2007 23:15 GMT
"Marc Gravell" <marc.gravell@gmail.com> schrieb:
> Use explicit values to get default(T) behaviour, with the 0 item being
> the default.

... or 'Nothing' in VB.

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.