This may seem like a simple question but i am getting an error when compiling this. I want to be able to pass an enum into a method in C.
Enum
enum TYPES { PHOTON, NEUTRINO, QUARK, PROTON, ELECTRON };
Calling the method
makeParticle(PHOTON, 0.3f, 0.09f, location, colour);
Method
struct Particle makeParticle(enum TYPES type, float...
Say I have enum as follows (taken from MSDN example):
enum Days {Sat=1, Sun, Mon, Tue, Wed, Thu, Fri};
I can then use is in the code as follows:
int today = (int)Days.Sun;
Question:
Can I evaluate enums? Say I have a variable Day whose value is "Sun".
Will Days.Day evaluate to Days.Sun?
Thanks!
Please don't get hung up on the d...
Sorry if the title is unclear - not sure how to phrase it. Feel free to edit it.
I have a web service written in C# and it uses an enum. When I am consuming this webservice with Flash, I had Flex generate the proxy classes - which also generates said enum in Actionscript. My problem is that I don't know how to use this generated Actions...
This code is taken from a SCJP practice test:
3. public class Bridge {
4. public enum Suits {
5. CLUBS(20), DIAMONDS(20), HEARTS(30), SPADES(30),
6. NOTRUMP(40) { public int getValue(int bid) {
return ((bid-1)*30)+40; } };
7. Suits(int points) { this.points = points; }
8. private i...
With GCC, I could do packing of enums using attribute((packed)), but it seems the closest thing in MSVC, #pragma pack, does not work on enums. Does anyone know of a way to pack enums into 1 byte instead of the usual integer size?
...
Hi I am using enums converted to a string with a switch but it doesn't work. It gives compilation error: Cannot implicitly convert type 'userControl_commontop.UserType' to 'string'
The code is:
private void CommonTopChangesnew(string usertype)
{
switch (usertype.Trim().ToUpper())
{
case UserType.NORMAL :
hl...
Hi guys, How can I parse a string in VB.NET to enum value?
Example I have this enum:
Public Enum Gender
NotDefined
Male
Female
End Enum
how can I convert a string "Male" to the Gender enum's Male value?
...
I've been trying to read a bit of the C++ standard to figure out how enum's work. There's actually more there than I originally thought.
For a scoped enumeration, it's clear that the underlying type is int unless otherwise specified with an enum-base clause (it can be any integral type).
enum class color { red, green, blue}; // these ...
I'm trying to create an Enum that has a string label and a value and I plan to use this to read stuff from an ini file.
For example in the ini file I might have some double, int or string type values preceded by the tag/name of the value:
SomeFloat = 0.5
SomeInteger = 5
FileName = ../Data/xor.csv
When I read the tag from a file it co...
How can I get the number of items defined in an enum?
...
I'm building an application that needs to compile on both Windows and Linux. The application is written in C, almost everything works except the MinGW compiler refuses this
typedef struct somestruct{
...snip...
enum {NODE, REAL} type;
};
somestruct* something;
switch (something->type){
case NODE:
...stuff...;
break;
case ...
For people suggesting throwing an exception:
Throwing an exception doesn't give me a compile-time error, it gives me a runtime error. I know I can throw an exception, I'd rather die during compilation than during runtime.
First-off, I am using eclipse 3.4.
I have a data model that has a mode property that is an Enum.
enum Mode {on(......
I am trapping a KeyDown event and I need to be able to check whether the current keys pressed down are : Ctrl + Shift + M ?
I know I need to use the e.KeyData from the KeyEventArgs, the Keys enum and something with Enum Flags and bits but I'm not sure on how to check for the combination.
...
From iPhone UIControl
UIControlEventAllTouchEvents = 0x00000FFF,
UIControlEventAllEditingEvents = 0x000F0000,
UIControlEventApplicationReserved = 0x0F000000,
UIControlEventSystemReserved = 0xF0000000,
UIControlEventAllEvents = 0xFFFFFFFF
Now I assume the UIControlEventApplication is the 'range' I can use to spe...
If you have a set of related words (e.g. Row & Column or On & Off), how do you find the collective word that describes those words? Specifically, how do you name an enum?
If I have "Red", "Green" and "Blue", a sensible enum name might be "Color". Values of "On" and "Off" might have a sensible enum name of "Power". But how do I name t...
Hi,
Let's consider the following enum in C#
public enum ScrollMode : byte
{
None = 0,
Left = 1,
Right = 2,
Up = 3,
Down = 4
}
The F# code receives a byte and has to return an instance of the enum
I have tried
let mode = 1uy
let x = (ScrollMode)mode
(Of course in the real application I do not get to set...
Is there a template or something for generating a switch statement for Java enum in Eclipse?
So that when I got an enum and I want to have a switch with all the values, I didn't have to write all it myself?
...
Hello guys,
Is it possible to enumerate every function present in a DLL ? How about getting its signature ?
Can I do this in C# ? Or do I have to go low level to do this?
Regards and tks,
Jose
...
is it possible to make a default typecast for an enum?
I use enum for a lot, such as states and I want to compare enums directly to LINQ fields, but I have to typecast all the time.
...
Hi, I have searched around and it seems very easy to bind enums to combobox, just retrieve Enum values as a list of strings via an ObjectDataProvider from the static Enum.GetValues method, however i can't get it to work. The error is Type ContactExportType was not found.
I have an enum called ContactExportType, it resides on Enums cl...