Questions tagged [enum-flags]
167 questions
2
votes
5 answers
Testing for multiple flag values
I have this flag enumeration:
public enum AssignmentType
{
None = 0,
Attendant = 1,
ConductorCBS = 2,
ReaderCBS = 4,
Chairman = 8,
Mike = 16,
PlatformAttendant = 32,
Prayer = 64,
OCLM = 128,
Sound = 256,
…

Andrew Truckle
- 17,769
- 16
- 66
- 164
2
votes
2 answers
Operator '&' cannot be applied to operands of type 'T' and 'T', where T : Enum
I have this enum with Flags attribute
[Flags]
public enum Animal
{
Null = 0,
Cat = 1,
Dog = 2,
CatAndDog = Cat | Dog
}
And use C# 7.3 which allows type constraints like:
where T : Enum
I create some extension method:
public static…

Степан Ермаков
- 35
- 3
2
votes
1 answer
How can I get "lowercase" namespace with cls.__members__ to work?
So I have written this module:
plaform.py
from enum import IntFlag
class PlatformFlag(IntFlag):
LINUX = 1,
MACOSX = 2,
WINDOWS = 3
globals().update(PlatformFlag.__members__)
And I am trying to use it this way:
import platform
if…

John Smith
- 465
- 4
- 15
- 38
2
votes
3 answers
How get not containing flags
I have enum flags. How to get all combinations of flags that do not contain a specific one?
[Flags]
public enum TestEnum
{
A = 1,
B = 2,
C = 4,
D = 8
}
public static IEnumerable AllNotContaining(this Enum value)
{....}
For…

panmigal
- 101
- 2
- 7
2
votes
4 answers
Getting common flags enum value in c#
Say I have the below enum
[Flags]
enum Letters
{
A = 1,
B = 2,
C = 4,
D = 8,
E = 16,
F = 32,
AB = A | B,
All = A | B | C,
}
If I have the variables:
var s = Letters.A | Letters.B | Letters.D;
var p =…

SP1
- 1,182
- 3
- 22
- 47
2
votes
2 answers
How to clear higher bytes in C# Flags Enum
I am using a Flags Enum to track the completion stages of a data migration process for each data record. I need a way to reset back to a specified stage where I can begin reprocessing the migration of a data record. How does one reset the higher…

Jack Pines
- 473
- 4
- 13
2
votes
2 answers
How to reduce code duplication in ASP.NET MVC view when working with Flags enum
Forgive my ignorance. Not done a lot of MVC work, and I'm sure there must be a better way to do this but I can't seem to find it. I have a Flags enum like this:
[Flags]
public enum Services
{
Foo = 1,
Bar = 2,
Meh = 4
}
And a…

Bob Tway
- 9,301
- 17
- 80
- 162
2
votes
1 answer
2
votes
3 answers
C# Enum Flag - two ways binding - enum - class -enum
I have the following enum
[Flags]
public enum WeekDays
{
Monday = 1,
Tuesday = 2,
Wednesday = 4,
Thursday = 8,
Friday = 16,
Saturday = 32,
Sunday = 64
}
In the UI, user can select ceratain days: Monday, Tuesday,…

user2818430
- 5,853
- 21
- 82
- 148
2
votes
2 answers
Get all containing flags
I have a variable containing some flags and wounder how I'm able to check which flags that are set.
My flags.
[Flags]
public enum Button{
//Can't have more than 30 flags
//If an enum is added or deleted need to change for loop…

Olof
- 776
- 2
- 14
- 33
2
votes
2 answers
How do you test an enum flag combination?
Let’s say I have an enum flag:
[Flags]
public enum ColorType
{
None = 0,
Red = 1 << 0,
White = 1<<1,
Yellow = 1 << 2,
Blue = 1 << 3,
All = Red | White | Yellow | Blue
}
I have the below function, which parameter is a…
user4143172
2
votes
3 answers
How to deal with calculated values with Dependency Properties on a custom WPF control
To summarize what I'm doing, I have a custom control that looks like a checked listbox and that has two dependency properties one that provides a list of available options and the other that represents a enum flag value that combines the selection…

jpierson
- 16,435
- 14
- 105
- 149
2
votes
2 answers
Set value to [Flags] Enum from list c#
I need to set the Enum value by items taken from the list.
I have Enum:
[Flags]
public enum EnumTest
{
Val1= 1,
Val2= 2,
Val3= 4
}
List with values:
var values = new List {EnumTest.Val1, EnumTest.Val3};
How can I get the…

Pavel
- 1,015
- 3
- 13
- 27
2
votes
2 answers
GroupBy using [Flag] enum grouping by single enum
Let's say I have
[Flags]
public enum MyEnum
{
ValueZero = 1,
ValueOne = 2,
ValueTwo = 4
}
public class MyClass
{
public string Property { get; set; }
public MyEnum EnumValue { get; set; }
}
I'd want to be able to use GroupBy on a…

IEatBagels
- 823
- 2
- 8
- 23
2
votes
1 answer
How to populate Qtablewidget with editable item and none editable item
every body
i have a problem in populating Qtablewidget with editable items for the first row , and then
non editable items for the rest of rows her is my implementation so far
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include…

advseo32
- 401
- 1
- 5
- 15