473,388 Members | 1,480 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,388 software developers and data experts.

How to initalize enum to null or blank?

11
Is there a way to initialize an enum to null/empty?

Expand|Select|Wrap|Line Numbers
  1. public enum Color
  2. {
  3.   Red,
  4.   Blue
  5. }
How to do something:
Color c = null;
or
Color c = "";
Dec 2 '10 #1

✓ answered by hype261

I believe you can create a Nullable enum like other value types. To declare a Nullable enum you just do...

Expand|Select|Wrap|Line Numbers
  1. Color? c = null;

2 28396
hype261
207 100+
I believe you can create a Nullable enum like other value types. To declare a Nullable enum you just do...

Expand|Select|Wrap|Line Numbers
  1. Color? c = null;
Dec 2 '10 #2
GaryTexmo
1,501 Expert 1GB
I'm sure you figured it out, but to any others reading this thread, remember that you need to access the Value property of a nullable type to get its value.

Pretty easy to spot, but still sometimes throws people for a loop :)
Dec 3 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Row | last post by:
HI, I would first like to say its been about 3 years since looking at java im very rusty! I have to write a post it notes type applet which will function online. (reading from a flat text file)...
2
by: www | last post by:
Hi there, I' m getting a (0x80040E2F) error, if I submit my form, with blank textboxes to my update stored procedure. The stored procedure expect values, so how can I detect if a form field was...
3
by: Cruisemate | last post by:
I created a report that utilized the sum function. however if there is a result that is 0 is doesn't display 0, it shows as null (blank) how can I get it to display the 0's in my report when there...
11
by: Charles Law | last post by:
Hi Guys I'm sure there is a plausible explanation for this, but ... <code> Public Enum Test Abra = 5 Cadabra = 76 End Enum
7
by: Harris | last post by:
Dear all, I have the following codes: ====== public enum Enum_Value { Value0 = 0, Value1 = 10,
34
by: Steven Nagy | last post by:
So I was needing some extra power from my enums and implemented the typesafe enum pattern. And it got me to thinking... why should I EVER use standard enums? There's now a nice little code...
3
by: hufaunder | last post by:
Imagine you have a charting library that can draw lines, bars, floating bars, bands, etc. Lines and bars need only one input. Floating bars and bands need two inputs. There are two approaches: ...
1
by: vaskarbasak | last post by:
hi all, I am using mysql db.The table structure is given below. +-----------------+---------------------------+------+-----+---------+-------+ | Field | Type ...
1
by: jrlittle86 | last post by:
I know I'm overlooking something very simple but How can I check if the text within an XML tag is blank? The code below works fine as long as there are values within an XML node (For example the...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.