All Questions
Tagged with value-type enums
11
questions
0
votes
0
answers
239
views
VB.NET If statement does something strange with Nullable Enum Type
I just ran into the following behavior that's so strange that I can't figure out how it could be correct.
Suppose I have an Enum like;
Enum MyEnum
...
End Enum
and a routine that returns a ...
3
votes
1
answer
865
views
Mutate a value-type associated value in-place
Is it possible in Swift to mutate an enum associated value, which is a value type? If yes, How?
struct S {
var a = 1
}
enum E {
case s(S)
}
var e = E.s(S())
// the goal is to make e ...
5
votes
2
answers
704
views
Enumeration type in c#
When we create variable of enumeration type and assign it an enumeration value
enum Members{HighlyQualified, Qualified, Ordinary}
class
{
static void Main()
{
Members developers = Members....
9
votes
1
answer
229
views
How to preserve value type in enum
Let's look at the following piece of code and assume that both MyAttribute and test function cannot be changed.
type MyAttribute() =
inherit Attribute()
let mutable prop = null
member ...
4
votes
2
answers
159
views
How to use macros for concise, type-safe, unboxed enum?
I am learning Scala macros and thinking of this as an exercise.
Is it possible to use Scala macros to write down something like this (maybe not exactly this concrete syntax, but something without ...
1
vote
2
answers
3k
views
How to declare a const field of a generic value type provided as generic argument
I'm trying to define a generic class that accept as argument a value type (actually it will be an enum) and initialize a const field with it's default type.
I want something like:
public abstract ...
12
votes
2
answers
6k
views
Using Integer vs String for a "type" value (Database and class design)
I've been developing a few mobile games, in which those games fetch their data from a server-database.
I'm used to storing "type" values as an integer identifier, and an enum in the client to ...
65
votes
4
answers
50k
views
Enum is Reference Type or Value Type?
I used Enum property in my EntityFramework 5 class,
but in the database this field is nullable. Visual studio gives the error that this property must be a nullable property. My question is: is Enum a ...
42
votes
1
answer
28k
views
Can AutoMapper Map Between a Value Type (Enum) and Reference Type? (string)
Weird problem - i'm trying to map between an enum and a string, using AutoMapper:
Mapper.CreateMap<MyEnum, string>()
.ForMember(dest => dest, opt => opt.MapFrom(src => src.ToString()...
7
votes
5
answers
4k
views
Set an enum to its default value
I'm sure this is fairly trivial but I can't get it right.
public static string DoSomething(this Enum value)
{
if (!Enum.IsDefined(value.GetType(), value))
{
// not a valid value, ...
103
votes
4
answers
48k
views
Test if an object is an Enum
I would like to know if 'theObject' is an enum (of any enum type)
foreach (var item in Enum.GetValues(theObject.GetType())) {
//do something
}