Questions tagged [enum-flags]
167 questions
1
vote
2 answers
Add working hours to correct price category based on week day and hours + holiday
I want to bind the correct amount of hours to correct work period. The work week is from Monday to Sunday. Based on the time of the day the work has different price. The work price based on time of the day when is done are called Periods. We are…

user2818430
- 5,853
- 21
- 82
- 148
1
vote
2 answers
Random value from c# enum variable
Is there an easy way for me to select a random bit value from my enum variable?
For example:
[System.Flags]
public enum Direction{
None = 0,
Up = 1,
Down = 2,
Left = 4,
Right = 8,
All = ~None
}
public Direction someDir =…

Alec Gamble
- 441
- 3
- 6
- 16
1
vote
1 answer
QFlags and QVariant
What I am trying to do is to simply store a QFlags in a QVariant.
The Flags definition:
class EnumObject : public QObject
{
Q_OBJECT
public:
enum DemoFlag {
SomeFlag0 = 0x00,
SomeFlag1 = 0x01,
SomeFlag2 = 0x02
};
…

Felix
- 6,885
- 1
- 29
- 54
1
vote
2 answers
Passing flags (or not) to a constructor in Java
Having methods with different names for roughly the same task makes sense, for example
open(String filename);
createThenOpen(String filename); // First create the file with default contents, then process the file.
This naming approach does not…

DustByte
- 651
- 6
- 16
1
vote
4 answers
Couldn't understand Enum Flags with 0x2 values
I am trying to understand a portion of code but couldn't understand it so far ...
[Flags]
public enum Products
{
Pepsi = 0x1,
Coca = 0x2,
Miranda = 0x3,
Dew = 0x4,
Wine = 0x5
}
Products pp = (Products)12;
pp.HasFlag(Products.Dew); ==>…

Waqar Ahmed
- 1,414
- 2
- 15
- 35
1
vote
1 answer
Combining multiple flags of an enum?
I've been trying to use multiple flags for the SpeechLibs Talk() function.
This is what I am trying to do:
V.Speak ("Text", SpeechVoiceSpeakFlags.SVSFlagsAsync + SpeechVoiceSpeakFlags.SVSFIsXML);
However, it gives me following error:
Error 1 …

Max
- 13
- 1
- 5
1
vote
2 answers
CA1008: Enums should have zero value and Flag enums
even when I'm completely aware of why the CA1008 warning exists I don't know how to avoid it in the following situation. I have a Flag enum with the following meanings:
ValidValue = 0x01
WrittenValue = 0x02
So in this case 0 means…

Ignacio Soler Garcia
- 21,122
- 31
- 128
- 207
1
vote
1 answer
Convert Flags from C# in Java
I'm translating a part of code from C# program to Java where is defined a [Flag] enum like this:
[Flags]
public enum ClientFlags
{
None = 0x00000000,
Flag1 = 0x00000001,
Flag2 = 0x00000002
...
And on runtime make…

Tommaso Giachi
- 13
- 4
1
vote
2 answers
Enum flags unexpected result
I'm using an enum as a flag
[Flags]
public enum SystemStatusEnum : long
{
Line_seizure = 1 << 0,
Off_hook = 1 << 1,
Initial_handshake_received = 1 << 2,
Download_in_progress = 1 << 3,
Dialer_delay_in_progress = 1 << 4,
…

Robby Smet
- 4,649
- 8
- 61
- 104
1
vote
2 answers
WPF DataBinding to Flag Enum (in a PropertyGrid)
I need to have the ability to select multiple values as is the nature of a Flag enumeration from a WPF view (all be it, in a PropertyGrid).
The properties in question are dynamic and no pre-defined DataTemplates can be used as the type of the…

holsee
- 1,974
- 2
- 27
- 43
1
vote
1 answer
Is there an intuitive way of checking for flags and states?
Couldnt find a relevant answer to my case so i will try explaining my situation:
I have the following code:
enum Flags {
OnlySpaces = 1 << 0,
valComment = 1 << 1,
valCommentBlock = 1 << 2,
valLabelName = 1 << 3,
…

RaptorX
- 331
- 1
- 9
- 19
0
votes
1 answer
Enum flag and None value
I was playing around with the SslPolicyErrors enum and noticed the following behavior:
SslPolicyErrors error = SslPolicyErrors.RemoteCertificateChainErrors
| SslPolicyErrors.None
|…

Jurgy
- 2,128
- 1
- 20
- 33
0
votes
1 answer
How can I get the active flags of a flag enum in an object in Typescript?
As the title suggests, I'm wondering if there's a way to do a similar thing as in C# with flag enums, where if the object is printed to IO, it prints out the flags that are active, instead of an integer they accumulate to.
Let's say I have a flag…

Galgarius
- 1
- 2
0
votes
1 answer
XAML Designer unable to resolve Enum types, 'base.enum' to 'mocks.enum_'
I have a C#/WPF MVVM program that uses a flagged enum to track the types of search mode the user is currently in and to manipulate the background colors of various controls depending on the given search modes. I am using an enum-to-bool converter…

Zinx
- 1
- 2
0
votes
1 answer
Is there a solution for a bitwise logical AND (&) operator between two Enum values in C#
Consider the following simple Flags Enum in C#:
[Flags]
public enum CountingEnum
{
Zero = 0,
One = 1 << 0,
Two = 1 << 1,
Three = Two | One,
Four = 1 << 2,
Five = Four | One,
}
If I want to know whether one value contains…

bopapa_1979
- 8,949
- 10
- 51
- 76