We help IT Professionals succeed at work.

enumerate decimals

sirbounty
sirbounty asked
on
Medium Priority
157 Views
Last Modified: 2010-04-23
I'm wondering if I'm understanding this correctly.

If I've got a movie admission class with the following enum

Public Enum AgeGroup
  Toddler = 0.00
  Student = 1.50
  Military = 1.00
  Adult = 3.00
  Senior = 1.00
End Enum

I get an error since option stict is on.  Other than turning it off, how would I set this up?
The error is ...implicit conversions from double to integer are disallowed...
Comment
Watch Question

High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
CERTIFIED EXPERT
Top Expert 2009
Commented:
Enums can't hold decimals...

From here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemenumclasstopic.asp

    "An Enum is a named constant whose underlying type is any integral type except Char."

If you really want to use an Enum then I guess you could store the values like 150, 100, or 300 and then divide them by 100 to get the actual value.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.