473,406 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

enum data type

Trying to declare a enum datatype.

Below works

Public Enum EnumCharSet
IBM037
IBM437
IBM500
End Enum

When I add a new string with a "-", error occur says that "End of statement
expected"

For example
Public Enum EnumCharSet
IBM037
IBM437
IBM500
ASMO-708
End Enum

Does not work because ASMO-708 has a "-" there.

What went wrong and what should I do?

regards,

Guoqi Zheng
http://www.ureader.com
Nov 19 '05 #1
4 3158
Notice that each named item in the enumeration is not enclosed in quotes.
Enumerated names are not strings; they're actually constants. If you look
at the IL of an enumeration, you'll see that your Enum is actually a class
that derives from System.Enum. Each name in the Enum becomes a Public Const
field of the class.

Because the names are not strings, the dash is interpreted as a minus sign
which is an illegal character in a type or variable name.

HTH
----------------
Dave Fancher
http://www.davefancher.com

"guoqi zheng" <no@sorry.com> wrote in message
news:77******************************@ureader.com. ..
Trying to declare a enum datatype.

Below works

Public Enum EnumCharSet
IBM037
IBM437
IBM500
End Enum

When I add a new string with a "-", error occur says that "End of
statement
expected"

For example
Public Enum EnumCharSet
IBM037
IBM437
IBM500
ASMO-708
End Enum

Does not work because ASMO-708 has a "-" there.

What went wrong and what should I do?

regards,

Guoqi Zheng
http://www.ureader.com

Nov 19 '05 #2
Basically, each enum value must follow the same naming constraints that any
varaible (symbol) would have.

"Dave Fancher" <da**@remove.davefancher.com> wrote in message
news:Xc********************@comcast.com...
Notice that each named item in the enumeration is not enclosed in quotes.
Enumerated names are not strings; they're actually constants. If you look
at the IL of an enumeration, you'll see that your Enum is actually a class
that derives from System.Enum. Each name in the Enum becomes a Public Const field of the class.

Because the names are not strings, the dash is interpreted as a minus sign
which is an illegal character in a type or variable name.

HTH
----------------
Dave Fancher
http://www.davefancher.com

"guoqi zheng" <no@sorry.com> wrote in message
news:77******************************@ureader.com. ..
Trying to declare a enum datatype.

Below works

Public Enum EnumCharSet
IBM037
IBM437
IBM500
End Enum

When I add a new string with a "-", error occur says that "End of
statement
expected"

For example
Public Enum EnumCharSet
IBM037
IBM437
IBM500
ASMO-708
End Enum

Does not work because ASMO-708 has a "-" there.

What went wrong and what should I do?

regards,

Guoqi Zheng
http://www.ureader.com


Nov 19 '05 #3
Thanks for all your replies, problem sloved now. it is better to use a class
in this situation.
Nov 19 '05 #4
Enumerations really boil down to syntactical convenience. Have you
considered using a Hashtable instead?

HTH
----------------
Dave Fancher
http://www.davefancher.com

"guoqi" <no@sorry.com> wrote in message
news:69******************************@ureader.com. ..
Thanks for all your replies, problem sloved now. it is better to use a
class
in this situation.

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Glenn Venzke | last post by:
I'm writing a class with a method that will accept 1 of 3 items listed in an enum. Is it possible to pass the item name without the enum name in your calling statement? EXAMPLE: public enum...
2
by: mrhicks | last post by:
Hello all, I have a question about enumerations. Within some requirements data passed back a certain bit field is defined by three bits then in another section the bit field is defined as 4...
21
by: Andreas Huber | last post by:
Hi there Spending half an hour searching through the archive I haven't found a rationale for the following behavior. using System; // note the missing Flags attribute enum Color {
5
by: Barry | last post by:
Hello, In VS2003, I tried using an enum and setting it into a field in a datarow. It seems as if the datatype of the field in the row determined what went into the field. If the datatype was...
34
by: Steven Nagy | last post by:
So I was needing some extra power from my enums and implemented the typesafe enum pattern. And it got me to thinking... why should I EVER use standard enums? There's now a nice little code...
35
by: dtschoepe | last post by:
Greetings. I am working on an assignment and can't seem to get the right concept for something I'm attempting to do with enum data types. I have defined the following in my code: enum color...
3
by: hufaunder | last post by:
Imagine you have a charting library that can draw lines, bars, floating bars, bands, etc. Lines and bars need only one input. Floating bars and bands need two inputs. There are two approaches: ...
10
by: Charlie | last post by:
I tried to post this before and I apologize if I am repeating myself, but I do not see the post anywhere. But anyway, I have a file, data.c, where I define all of my global variables. I then...
12
by: Charlie | last post by:
I have a file, data.c, where I define all of my global variables. I then have a header file, data.h, which I include in every file in which I reference all of the variables defined in data.c. ...
4
by: jonpb | last post by:
The documentation for the "is" keyword says: An is expression evaluates to true if the provided expression is non-null, and the provided object can be cast to the provided type without causing...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.