flags

  • Thread starter Thread starter ichor
  • Start date Start date
ichor said:
what does this at the begining of a class mean?
[Flags]

It marks an enum as being a set of flags(ie a bitfield). The only visible
effect you'll see while using C# is that ToString() recognizes it and
results in a list of values ("EnumVal1, EnumVal2" for example) instead of
the name of the singular enum value.

Its possible that in other languages, Flags may be required to perform & and
| 's against it.
 
hi ,
I want to simulate the chmod utility in unix where

chmod 777 gives everyone all access.

how do i create an enum so that 4 means read and write perm.

(read=1
write=3
full=7 not sure about chmod values for read write and execute.)

can anyone give me an idea how to go about it?
thnx


Daniel O'Connell said:
ichor said:
what does this at the begining of a class mean?
[Flags]

It marks an enum as being a set of flags(ie a bitfield). The only visible
effect you'll see while using C# is that ToString() recognizes it and
results in a list of values ("EnumVal1, EnumVal2" for example) instead of
the name of the singular enum value.

Its possible that in other languages, Flags may be required to perform & and
| 's against it.
 
frazer,
It is "rwx" binary bits repeated three times for owner, group and others.
In Unix, 4 is read, 2 write, and 1 execute. Therefore, read and write for
owner would be 600 octal.
In windows, unfortunately the Attrib command has ReadOnly, Archive, System,
and Hidden attributes.
Moreover, the permission are not divided into owner, group and everyone.
They are far more sophisticated.
While in C or C# you may simulate the bitfields, the O/S level equivalent is
hard to obtain.

Thanks,
Fakher Halim
Software Architect,
TPG

frazer said:
hi ,
I want to simulate the chmod utility in unix where

chmod 777 gives everyone all access.

how do i create an enum so that 4 means read and write perm.

(read=1
write=3
full=7 not sure about chmod values for read write and execute.)

can anyone give me an idea how to go about it?
thnx


Daniel O'Connell said:
ichor said:
what does this at the begining of a class mean?
[Flags]

It marks an enum as being a set of flags(ie a bitfield). The only visible
effect you'll see while using C# is that ToString() recognizes it and
results in a list of values ("EnumVal1, EnumVal2" for example) instead of
the name of the singular enum value.

Its possible that in other languages, Flags may be required to perform & and
| 's against it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top