Questions tagged [enum-flags]

167 questions
0
votes
2 answers

Compact non-repetitive way for an ALL flag in enums that represent bitflags in C++

I often use enums for bitflags like the following enum EventType { NODE_ADDED = 1 << 0, NODE_DELETED = 1 << 1, LINK_ADDED = 1 << 2, LINK_DELETED = 1 << 3, IN_PIN_ADDED = 1 << 4, IN_PIN_DELETED = 1 << 5, IN_PIN_CHANGE = 1…
0
votes
1 answer

The absence of a value in a dictionary

So I have a enumflag system and I need to filter by Narcotic, non-Narcotic, Psychotropic, and non-Psychotropic in a drop down list. My thinking was to put the values in dictionary and they viewbag into a selectlist on the front end, but I am having…
Mr9mm
  • 19
  • 3
0
votes
1 answer

C# How to choose enum (flag) value name then there are two enums for the same value (alias)?

Let's say we have this enum: [Flags] public enum SerialBaudRate { Default = _11520bps, _9600bps = 0, _19200bps = 1, _11520bps = 2, _230400bps = 3, _460800bps = 4, } and we want to print out the enum value using…
Vinigas
  • 464
  • 5
  • 18
0
votes
3 answers

How can I flag a integer to a generic list of enum?

I've search for a solution for my problem but so far i was not able to figure out how to do it. I need to get a list of values of an enum flagged by a int value. I was able to do it in a specific case, but I want to create a generic function for a…
0
votes
2 answers

c# Match shift that spans over midnight

I have the following netfiddle: .net fiddle How can I make it work by adding a period that spans over midnight like this: `new Period( "9", Days.Workdays, TimeSpan.FromHours(22), TimeSpan.FromHours(07) )` Notice from 22:00 (10:00 PM) to 07:00…
user2818430
  • 5,853
  • 21
  • 82
  • 148
0
votes
1 answer

Bitwise operations on Enum Flag

Assume you have the following Enumeration, which contains flags. [Flags] public enum MyFlag { None = 0, Foo = 1 << 0, Bar = 1 << 1, Baz = 1 << 2, Quuz = 1 << 3 } And you instantiate a new and old : var newF = MyFlag.Foo |…
0
votes
1 answer

XElement using Flags Enum

In my code, I have got an Flags Enum for days of the week, as follows: [Flags] public enum DaysOfWeek // enumeration for days of week { Sunday = 0x0000001, Saturday = 0x0000010, Friday = 0x0000100, Thursday = 0x0001000, …
StuartR143
  • 369
  • 2
  • 10
0
votes
2 answers

Gmod Lua - Checking if flag exists in bitflag

I am trying to check if a key is being pressed at the current frame in Gmod Lua with cmd:GetButtons(). In other words, I am trying to see if a flag exists in a bitflag in Lua. I am attempting the following code: -- flags = 1024 (when holding…
Ari Seyhun
  • 11,506
  • 16
  • 62
  • 109
0
votes
0 answers

How to select particular process against combinition of ids

I am sorry if the title is misleading. I have integer id's in such a way so that for particular pair of Id's, I have to execute a separate process in the application, while for other pair of ID's, other execution should be followed. How can I put…
Usman
  • 2,742
  • 4
  • 44
  • 82
0
votes
2 answers

Is there a way to convert from a list of strings to an enum flag in c#?

I have a list of strings in an xml document: red yellow blue and I have an enum: [Flags] public enum Properties { None = 0, red = 1, yellow = 2, blue = 4, green = 8 } Is there a way to convert the…
leigero
  • 3,233
  • 12
  • 42
  • 63
0
votes
2 answers

C# - Help with [Flags] Enum & Extension Method

I have the following enum: [Flags] public enum PostAssociations { None = 0x0, User = 0x1, Comments = 0x2, CommentsUser = 0x3 } As a starting note, im not sure if those flags are correct. I'm doing this so that i have a fluent way of…
RPM1984
  • 72,246
  • 58
  • 225
  • 350
0
votes
2 answers

Enum Flags conversions for Decimal values/names

I have few enum flags that represent a version of an external system. I want to ensure, that every time the external system upgrades its version, my functionality should be able to support it (I will know in advance that version will be upgraded, so…
touchofevil
  • 595
  • 4
  • 21
0
votes
3 answers

I want to know if or how I can use the flag enum and return the enum parameter in another class

I have a list of flag enums for input validation, I want to return one of the enums as part of my validation. So far this is what I come up with... These are my enums. [Flags] public enum CheckInput { Not_Valid, OK, No_First_Name, …
0
votes
1 answer

enum flags with name

I'm going to use enum flags for options to initialize my class. The enum is: namespace MCXJS { enum VARPARAM { STATIC = 1, CONST = 2 } //other things } If I'm right, in this case, to check for STATIC I need to do…
Xirdus
  • 2,997
  • 6
  • 28
  • 36
0
votes
3 answers

Howto get flags from enum value?

Trying to get array of all possible flags from enum value, say 3 to array of {1, 2}. I have an extension internal static MyEnum[] GetFlags(this MyEnum modKey) { string[] splitStr = modKey.ToString().Split(new string[1] { ", " },…
xnp
  • 51
  • 2
  • 6