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

How do you used Flags Attribute

Need example of how to use the flags attribute and to determine which flags
were set.

Nov 16 '05 #1
3 8308
I don't know about a flags attribute, but using flags shouldn't be a
problem.

bool flag = false;

if (......)
flag = true;

if(flag == true)
// DO SOMETHING

"Patrick Blackman" <ca*******@videotron.ca> wrote in message
news:eW**************@TK2MSFTNGP10.phx.gbl...
Need example of how to use the flags attribute and to determine which flags were set.

Nov 16 '05 #2
[Flags]
enum ActionAttributes {
Read = 1,
Write = 2,
Delete = 4,
Query = 8,
Sync = 16
}

This is how you define an enumerated type with the FlagsAttribute

To assign e.g. ActionAttributes aa = ActionAttributes.Read |
ActionAttributes.Write;

To check if aa has the Read Attribute e.g. if ( (aa &&
ActionAttributes.Read) == ActionAttributes.Read) {}

--
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
"Patrick Blackman" <ca*******@videotron.ca> wrote in message
news:eW**************@TK2MSFTNGP10.phx.gbl...
Need example of how to use the flags attribute and to determine which flags were set.

Nov 16 '05 #3
Thanks guys.....
"Patrick Blackman" <ca*******@videotron.ca> wrote in message
news:eW**************@TK2MSFTNGP10.phx.gbl...
Need example of how to use the flags attribute and to determine which flags were set.

Nov 16 '05 #4

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

Similar topics

4
by: Keith Hill | last post by:
Is there a way to represent a style enum in XML Schema? Say I have a flags enum like so: public enum dayOfWeek { Mon, Tue, Wed, All = Mon | Tue | Wed; }
4
by: siddurampure | last post by:
why flags r used in c langauage
10
by: Jose Ines | last post by:
Hello, Can anyone give me a link where I can find a tutorial on how to make enumaration flags? Not the structure (public enum MyFlags{...}) but how to asign the members values (0x01, 0x02) etc......
3
by: Matt Burland | last post by:
I wanted to set up a enum to represent certain properties of an object that can be combined. So I'm using the FlagAttribute with my enum and adding them to by objects with | (or). But what is the...
0
by: cody | last post by:
I propose that if an enum has FlagsAttribute set and its member have not they values explicitly assigned I'd propose that the compiler should emit a warning. Also if fields are not power of two (or...
4
by: Paul E Collins | last post by:
The help file says that "bit fields can be combined using a bitwise OR operation, whereas enumerated constants cannot", and yet this code works: enum Blah { a, b, c }; // without .... Blah x...
4
by: Joel Moore | last post by:
Say I have an enum similar to this: <Flags()> Enum TestFlags As Short One = 0 Two = 1 Three = 2 Four = 4 End Enum I figured I could declare variable of type TestFlags to be used in the
2
by: Jigar.Patel | last post by:
Hi, I have following enum definition. public enum OperationTypes { All = 1, New = 2, View = 4,
7
by: IanWright | last post by:
I should know how to do this but I unfortunately don't, so I'd just like to clarify... I've got a Flags enum: public enum SkillSet { Skill1 = 1, ...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.