Questions tagged [enum-flags]
167 questions
1
vote
1 answer
Get all values represent decimal value in flag enum
I am using typescript to declare enum of type flag as following
export enum OperatorEnum{
None = 0x0,
Equal = 0x1,
NotEqual = 0x2,
GreaterThan = 0x4,
LessThan = 0x10,
GreaterOrEqual = 0x20,
LessOrEqual = 0x40,
…

s.alhaj
- 141
- 2
- 11
1
vote
1 answer
How to find elements in a list of custom objects that have specific value of [Flags] enum
Given this enum:
[Flags]
public enum Result
{
None = 0,
Draw = 1 << 0,
Win = 1 << 1,
Loss = 1 << 2,
NotLost = Draw | Win,
NotWon = Draw | Loss,
Any = Draw | Win | Loss
}
and this class:
public class Match
{
public…

BeNes
- 88
- 7
1
vote
2 answers
Why is StringSplitOptions tagged with the Flags attribute in C#?
I was looking at the summary of the StringSplitOptions enum and and then was surprised to see it has the Flags attribute applied to it.
The Flags enum is relevant for things like BindingFlags where you'd like to do things like BindingFlags.Public |…

nalka
- 1,894
- 11
- 26
1
vote
1 answer
Building a list of enum flags
I have this method that accepts multiple JobSetting flags
private void ProcessTheData(string[] dataFiles, PictureBox sender, JobSetting? jobSetting)
The Flags enum is this
[Flags]
enum JobSetting
{
ForcePrint = 1,
ForceProof = 2,
…

blaze_125
- 2,262
- 1
- 9
- 19
1
vote
1 answer
Passing enum flags to a class or procedure
I would like to pass multiple enum (bitwise) items to a procedure. Not separately but and'd together similar to the Messagebox command. eg:
MsgBoxStyle.Exclamation + MsgBoxStyle.OkCancel
There's plenty of info on the Flagg option etc but not on how…

Derek_83327
- 13
- 3
1
vote
1 answer
Is it possible to do bitwise operations on string flags within the class definition?
I have created a custom class that extends enum.Flag:
from enum import Flag
class StrFlag(Flag):
def __new__(cls, verbose):
value = len(cls.__members__)
obj = object.__new__(cls)
obj._value_ = 2 ** value
…

Bartleby
- 1,144
- 1
- 13
- 14
1
vote
1 answer
How to store Processor Status flags' values with corresponding enum for 6502
I'm working on 6502 emulator in C++ as a part of my thesis. It has 6 registers, most of them just hold values but there's one special - Processor Status. It's 8 bit wide and each bit means a different flag. The best choice for me seemed to make it…

Sebastian Kucharzyk
- 85
- 7
1
vote
1 answer
How can I use bitwise OR on an enum and an int?
I have a flag Enum called Role and an extension method called AddRole, that takes a Role enum and an int that works like a flag and only contains ones and zeros, where each 1 represents a role that a person has. I want the method to add the role to…

agnete
- 13
- 3
1
vote
1 answer
GetHashCode returning same Value for the different Bit Flag Enums
I have Flag type Enum with bitwise representation for each element as below
[DataContract]
[Flags]
public enum TestProduct : long
{
[EnumMember]
A1 = 0x1,
[EnumMember]
A2 = 0x2,
[EnumMember]
A3 = 0x4,
[EnumMember]
A4…

user2081126
- 77
- 1
- 11
1
vote
1 answer
WPF Enum Flags Dependency property in XAML property editor
I am developing custom WPF UserControl which has few Dependency Properties. One of the properties is enum flags. I am trying to check if it is possible to set this property from Designer in property grid.
Here is the property
public Letters…

Ihar I.
- 11
- 3
1
vote
1 answer
Best way to initialize a python flag utility class?
I'm working a on a utility class in Python3.7 that makes using flags more user friendly (to me, at least)
Basically, I want to turn this
from enum import Flag as eFlag, auto, unique
@unique
class Flag(eFlag):
A = auto()
B = auto()
flags =…

Kurt E. Clothier
- 276
- 1
- 11
1
vote
1 answer
Combine flags of generic Enum
According to this answer we can have generics constrained to System.Enum since C# 7.3.
However, while one can check any flag of an unkown Enum with
HasFlag(Enum flag)
it is not possible so set a flag of an unkown Enum, since there is no SetFlag()…

SmallestUncomputableNumber
- 243
- 2
- 13
1
vote
1 answer
Pass / Get multiple Enum values in Typescript?
Pass value which is the combination of enum values and get the corresponding enum strings of it.
Here is my scenario,
enum EnumDays {
NONE = 0,
SUN = 1,
MON = 2,
TUE = 4,
WED = 8,
THU = 16,
FRI = 32,
SAT = 64,
…

SuganR
- 129
- 1
- 10
1
vote
2 answers
CLR - Declare enum with "Flags" attribute
I have the following Enum in CLR / CLI:
public enum class Days
{
Sunday,
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday
};
In C#, if I wanted to create a combination of the selected enums, I used to add [Flags]…

Nave Tseva
- 371
- 2
- 6
- 16
1
vote
1 answer
SDL_GetWindowFlags() returns seemingly random values
I need my SDL2 program to know whether a window is fullscreen, and I thought I could get that info using SDL_GetWindowFlags(). By default I initialize my window with two flags: SDL_WINDOW_SHOWN and SDL_WINDOW_BORDERLESS, which are equal to 16 and 4…

lokus
- 57
- 7