Questions tagged [enumeration]

The process of enumerating values, for example from some collection.

Use for enumeration types.

1894 questions
20
votes
2 answers

How to convert an enum value to a string?

I know I have been able to do this before, long ago, so it must be possible. I'd like to convert an item, such as a component's align property alNone, to a string that I can save, display, whatever. I know I can get the byte value and the come up…
M610
  • 225
  • 1
  • 2
  • 10
20
votes
3 answers

Difference between associated and raw values in swift enumerations

Swift enumerations have both associated and raw values. But the use cases of these values is not clear to me. So I would really appreciate if anyone can explain the difference between the associated and raw values, an example would be very helpful.
Ankit Goel
  • 6,257
  • 4
  • 36
  • 48
19
votes
4 answers

Large flags enumerations in C#

Hey everyone, got a quick question that I can't seem to find anything about... I'm working on a project that requires flag enumerations with a large number of flags (up to 40-ish), and I don't really feel like typing in the exact mask for each…
LorenVS
  • 12,597
  • 10
  • 47
  • 54
19
votes
1 answer

Entity Framework enumerating SqlQuery result

I have strange error while I am trying to view results of SqlQuery: var sql = "SELECT @someParam"; var someParamSqlParameter = new SqlParameter("someParam", "Some Value"); var result = _dbContext.SqlQuery(sql, someParamSqlParameter); var…
Vladimirs
  • 8,232
  • 4
  • 43
  • 79
18
votes
4 answers

Difference between enum and Enumeration

Is there any difference between enum datatype and Enumeration Interface. I have become confused between the two. I got my answer that they aren't related but that brings me to another question. We cannot instantiate interface . So what is the…
chetan mehta
  • 369
  • 1
  • 3
  • 13
17
votes
3 answers

Delphi for..in loop set enumeration order

I want to iterate through a set of specific values. Simple example below program Project1; {$APPTYPE CONSOLE} var a, b: word; wait: string; begin a := 0; for b in [1,5,10,20] do begin a := a + 1; writeln('Iteration = ', a, ', …
HMcG
  • 2,062
  • 4
  • 24
  • 36
17
votes
4 answers

Does GetCustomAttributes() preserve the attribute order in .NET?

The title pretty much says it all. When I'm doing some reflection through my classes, will the MemberInfo.GetCustomAttributes() method preserve the order of attributes on a member, or not? The official documentation does not say anything one way or…
Vilx-
  • 104,512
  • 87
  • 279
  • 422
17
votes
1 answer

How to use "enumerateChildNodesWithName" with Swift in SpriteKit?

I'm using Swift to make a game in SpriteKit. In Objective-C I could use the following method: (void)enumerateChildNodesWithName:(NSString *)name usingBlock:(void (^)(SKNode *node, BOOL *stop))block to perform actions on that *node, but I can't get…
rv123
  • 476
  • 1
  • 3
  • 14
17
votes
2 answers

Why and how (internally) does Enum.IsDefined search for both name and value?

Lets say we have defined Planets enum: public enum Planets { Sun = 0, Mercury=5, Venus, Earth, Jupiter, Uranus, Neptune } I was using Enum.IsDefined method for…
Farhad Jabiyev
  • 26,014
  • 8
  • 72
  • 98
16
votes
1 answer

Where is .. defined?

I'm just wondering whether .. is actually defined in Haskell code anywhere, like in the Prelude? Is enumFromTo the same thing? I don't get which is the definition? enumFromTo x y = map toEnum [fromEnum x .. fromEnum y] [ e1 .. e3 ] = …
js2010
  • 23,033
  • 6
  • 64
  • 66
16
votes
7 answers

Treat Enumeration as Iterator

I have a class that implements the Enumeration interface, but Java's foreach loop requires the Iterator interface. Is there an Enumeration to Iterator Adapter in Java's standard library?
fredoverflow
  • 256,549
  • 94
  • 388
  • 662
16
votes
3 answers

Enumerate NSDictionary with keys and objects, PHP style

I know you can Enumerate the keys or values of NSMutableDictionary using NSEnumerator. Is it possible to do both together? I'm looking for something similar to the PHP foreach enumerator like: foreach ($dictionary as $key => $value);
typeoneerror
  • 55,990
  • 32
  • 132
  • 223
16
votes
9 answers

How to read a properties file in java in the original order

I need to read a properties file and generate a Properties class in Java. I do so by using: Properties props = new Properties(); props.load(new FileInputStream(args[0])); for (Enumeration e = props.propertyNames(); e.hasMoreElements();)…
wen
  • 681
  • 1
  • 7
  • 17
16
votes
3 answers

In java, What does such enum type compile to?

Below is the code that defines enum type. enum Company{ EBAY(30), PAYPAL(10), GOOGLE(15), YAHOO(20), ATT(25); private int value; private Company(int value){ super(this.name()); this.value = value; } public int…
overexchange
  • 15,768
  • 30
  • 152
  • 347
16
votes
1 answer

Strange thing about .NET 4.0 filesystem enumeration functionality

I just read a page of "Whats new .NET Framework 4.0". I have trouble understanding the last paragraph: To remove open handles on enumerated directories or files Create a custom method (or function in Visual Basic) to contain your enumeration…
codymanix
  • 28,510
  • 21
  • 92
  • 151