Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8177879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:37:56+00:00 2026-06-06T23:37:56+00:00

I have three enums: enum ValueType : int { FloatingPoint = 2, …/… }

  • 0

I have three enums:

enum ValueType : int
{
  FloatingPoint = 2,
  .../...
}
enum ConstraintType : int
{
  Range = 2,
  .../...
} 
enum Parameter : int 
{
  ExposureTime = F(ValueType.FloatingPoint, ConstraintType.Range, 23),
  .../...
}

The problem is in the signature of F if I use:

private static int F(ValueType _V, ConstraintType _C, int _N) { ... }

I get an error (invalid arguments) for every call in the definition of Parameter, but if I use the following instead:

private static int F(int _V, int _C, int _N) { ... }

Everything is fine.

It’s not a blocking problem, but I’d like to understand why is that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T23:37:59+00:00Added an answer on June 6, 2026 at 11:37 pm

    The C# spec states in section 14.3 (“Enum members”) that

    Within an enum member initializer, values of other enum members are
    always treated as having the type of their underlying type, so that
    casts are not necessary when referring to other enum members.

    As far as I can tell this is why the arguments appear to have a type of int. It’s interesting to note that this will not result in an invalid argument error:

    ExposureTime = F((ValueType)ValueType.FloatingPoint, 
                     (CostraintType)ConstraintType.Range,
                     23),
    

    Of course it will still result in another error because you cannot use a method call to initialize enum members as Marc says. A method call is not a constant expression, while

    The associated value of an enum member is assigned either implicitly
    or explicitly. If the declaration of the enum member has a
    constant-expression initializer, the value of that constant
    expression
    , implicitly converted to the underlying type of the enum,
    is the associated value of the enum member. If the declaration of the enum member has no initializer, its associated value is set implicitly […]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Morning, I have three tables: Table: debtors id - INT(11) type - ENUM('c', 'p')
I have the three following enums: public enum SensorTypeA{A1,A2,...,A12}; public enum SensorTypeB{B1,B2,...,B12}; public enum
I have three enums, which - in combination - should identify a unique state
I'd like to use the same enum across three tiers of my application (presentation
I have enums in one of my windows application like below: private enum ModificationType
i have problem with enum I need make a enum in base class or
I have three different Enum and all of three has same identifier but different
I have a MySQL Left Join problem. I have three tables which I'm trying
I have a bunch of different enums, such as... public enum MyEnum { [Description(Army
I have read about Java enums and use them regularly. However, I don't understand

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.