I've the given condition from a cpp source.
if (!(faces & activeFace) || [...]) { ... }
I want to translate this into C#.
When I understand this right, this means as much as if activeFace is *not* in faces then...
- not?
So what would be the equivalent in C#?
Note: I can't use faces.HasFlag(activeFace)
Well it should be
if ((faces & activeFace) == 0 || [...]) { ... }
Am I right?
For the completeness here the actual Flag enum
[Flags]
enum Face {
North = 1,
East = 2,
South = 4,
West = 8,
Top = 16,
Bottom = 32
};
Well It's the same in cpp, you just need to add a [Flags]
attribute in C#
Am I right?
Yes. Question solved? – Fossilize[Flags]
attribute in C#. Your code will work just fine without it. – Fossilizeapt-get install gcc ; gcc test.cpp
(or whatever the actual command would be) - so: no. – LyndenFlagsAttribute
when the enum is used as flag, i.e. if its constants are powers of 2, as this expresses the intention of the programmer. The attribute also influences the wayToString
works and produces a neat output if flags are combined. This is useful when debugging. – Cuculiform[Flags]
changedToString()
! I guess you learn something new every day. – Fossilize