473,383 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Assigning Default value to Enum Variable

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

Mar 14 '07 #1
2 6420
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
Mar 14 '07 #2
"Marc Gravell" <ma**********@gmail.comschrieb:
Use explicit values to get default(T) behaviour, with the 0 item being
the default.
.... or 'Nothing' in VB.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Mar 14 '07 #3

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

Similar topics

20
by: Glenn Venzke | last post by:
I'm writing a class with a method that will accept 1 of 3 items listed in an enum. Is it possible to pass the item name without the enum name in your calling statement? EXAMPLE: public enum...
4
by: Carlos Gomez | last post by:
In VB6 the default for passing variables was ByRef. It was faster and used less memory. Why did MS changed that? Are there any advantages using ByVal over ByRef? (other than ByVal impeding you from...
4
by: Dennis | last post by:
I am trying to set the default design proerties in a control I have derived from the Panel Class. I thought I'd found how to do it from the MSDN but the following line doesn't work: Inherits...
3
by: Scott Liu | last post by:
HI, All, I have a web service doing a string search. It has an operator and a searchValue field. The operator is defined as an attribute and required. The xml is as below. <!--...
4
by: veerleverbr | last post by:
Suppose having define an enum like this: public enum SomeEnum { Something, SomethingElse }
12
by: aaragon | last post by:
Hello all. I have a simple question that seems trivial but I can't make it to work. I have a class that takes as a template argument, another class. The idea is as follows: #include...
2
by: Lucky | last post by:
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 : public enum check {
4
by: Macneed | last post by:
i am a newbie, i remember i read a book talking about when u declare a array variable using float ABC = new float; the whole array element in ABC ( ABC to ABC ) will automatic initialize to 0...
7
by: Travis | last post by:
I'm curious, if you have an enum say... enum Days { Mon, Tue, Wed, Thu, Fri, Sat, Sun }; I understand the default will be Mon=0, Tue=1, Wed=2, etc. What I'm curious about is if there is a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.