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

Enum - VS2005 Beta2

Hi,

I have been playing around with Enum and looking at the example in the help

enum Colors { Red = 1, Green = 2, Blue = 4, Yellow = 8 };

Colors myColors = Colors.Red | Colors.Blue | Colors.Yellow;

Console.WriteLine("myColors holds a combination of colors. Namely: {0}",
myColors);

This will display Red | Blue | Yellow

Is there a way of testing what is in myColors on an individual basis?

TIA

Colin B


Nov 17 '05 #1
4 1142
>Is there a way of testing what is in myColors on an individual basis?

You mean like

if ((myColors & Colors.Blue) != 0) ...

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 17 '05 #2
KH
You should use the [Flags] attribute on the enum for this purpose.
"Colin Basterfield" wrote:
Hi,

I have been playing around with Enum and looking at the example in the help

enum Colors { Red = 1, Green = 2, Blue = 4, Yellow = 8 };

Colors myColors = Colors.Red | Colors.Blue | Colors.Yellow;

Console.WriteLine("myColors holds a combination of colors. Namely: {0}",
myColors);

This will display Red | Blue | Yellow

Is there a way of testing what is in myColors on an individual basis?

TIA

Colin B



Nov 17 '05 #3
Hi there,

yes that kind of thing indeed!

cheers
Colin

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:ex**************@TK2MSFTNGP12.phx.gbl...
Is there a way of testing what is in myColors on an individual basis?


You mean like

if ((myColors & Colors.Blue) != 0) ...

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 17 '05 #4
Hi,

having started out assembler programming, this Flags thing really makes the
whole construct pretty darn sexy!

thanks for that, awesome!
Colin
"KH" <KH@discussions.microsoft.com> wrote in message
news:2B**********************************@microsof t.com...
You should use the [Flags] attribute on the enum for this purpose.
"Colin Basterfield" wrote:
Hi,

I have been playing around with Enum and looking at the example in the
help

enum Colors { Red = 1, Green = 2, Blue = 4, Yellow = 8 };

Colors myColors = Colors.Red | Colors.Blue | Colors.Yellow;

Console.WriteLine("myColors holds a combination of colors. Namely: {0}",
myColors);

This will display Red | Blue | Yellow

Is there a way of testing what is in myColors on an individual basis?

TIA

Colin B



Nov 17 '05 #5

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

Similar topics

7
by: DaVBGuy | last post by:
I'm currently using VB 6 for windows based apps. Should I make the jump to VS.2003 now, or should I wait till (the final) VS.2005 release comes out later this year. If I have not started...
2
by: Gustavo L. Fabro | last post by:
Greetings. I had an user control built on Visual Studio 2003 that I used in some forms build also with Visual Studio 2003 (C++ was the language for both cases). Now I'm trying to port this to...
3
by: Robert | last post by:
I have an application with custom configuration sections in it's app.config file. Here's a shortened excerpt: <monitors> <monitor...
2
by: Eric Connell | last post by:
I'm interested in porting an existing app to Visual Studio .NET 2005 (ASP.NET 2.0). I need to hit a windows 2003 server with a SQL Server 2000 database. I want to use the server to host my web...
1
by: Martin Bischoff | last post by:
When I build my web site (debug build), the bin folder contains pdb files for every referenced assembly (also part of my solution). When opening the "pending checkins" window, all DLLs and PDBs in...
9
by: Liddle Feesh | last post by:
Can I do this? Will the two environment and frameworks co-exist? I will later on wish to change the VS2005 Beta2 installation into the full VS2005 installation (also still keeping VS2003). ...
9
by: João Santa Bárbara | last post by:
Hi all, i have instaled VS2005 Develpers Edition, and i have migrate my VB code from VS2003 to VS2005(RTM). and so far i´m not pleased with this migration. i have lots of ide Bugs, some forms...
56
by: Rob Dob | last post by:
VS2005 is a PIECE of Garbage and is bug Ridden, I wonder how many others feel the same, I am so sorry that I have moved away from VS2003, VS2005 is unstable, and half the stuff doesn't work, ...
11
by: MSNEWS | last post by:
HI Public Enum WindowStyles As UInteger WS_OVERLAPPED = 0x00000000 WS_POPUP = 0x80000000 WS_CHILD = 0x40000000 end enum In the above i get an error at
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
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
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...
0
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...

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.