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 1095537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:08:31+00:00 2026-05-17T00:08:31+00:00

Possible Duplicate: C# int, Int32 and enum's It could be a rather basic /

  • 0

Possible Duplicate:
C# int, Int32 and enum's

It could be a rather basic / simpler question
I am creating an enum in the following way.

Case 1 does compile perfectly. But Case 2 throws an error.
To my understanding int and Int32 mean the same in C#.

Case 1

    [Flags]
    public enum MyEnum : int
    {
        Red = 0x1,
        Green = 0x2,
        Blue = 0x4
    }

Case 2

    [Flags]
    public enum MyEnum : Int32
    {
        Red = 0x1,
        Green = 0x2,
        Blue = 0x4
    }

What’s the difference here and why C# doesn’t compile the code when the enum’s members are specified to be of Int32 type?

  • 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-05-17T00:08:31+00:00Added an answer on May 17, 2026 at 12:08 am

    From a Microsoft bug report here:

    Symptom
    If you use System.Int16/Int32/Int64 instead of Short/Int/Long to declare Enum, it will get compilation error.

    Root Cause
    It’s by design. Using value type alias is required exactly in Enum declaration.

    It is “by design”.

    1. The syntax is correct. C# specification explicitly states that the enum’s underlying type must be byte, sbyte, short, ushort, int, uint, long or ulong.

    2. Although the underlying type of “Short” and “System.Int16” are one and the same, they are not as identical as you assume. The System.Int16 is a type, and the Short is a type keyword.

    3. ValueType is sealed. You cannot inherit from any class that derives from System.ValueType.

    4. But, it allows you to use the keyword to control. The intent is to prevent your using names of any types that derive from System.ValueType when declaring other types. The original intent is to provide a tightly controlled mechanism that allows you to declare types that inherit from System.ValueType.
      However, MSDN says “The C# type keywords and their aliases are interchangeable”, which often let customers feel confused/inexplicable. They think it’s a compiler or grammar bug.

    Business Impact / Customer Experience
    Since the “Short” and “System.Int16” are the same one underlying type and can be interchangeable, many customers feel confused/inexplicable why it cannot be interchangeable in Enum declaration. They think it’s a compiler or grammar bug.
    The Voice of customers:
    This sounds like a small compiler bug (small becuase its easy to workaround).
    Here is what MSDN says “The C# type keywords and their aliases are interchangeable.”
    In my view this is a real but tiny, compiler (or perhaps grammar) bug.
    The fact that the compiler lets you use “short” here and not “System.Int16” is a quirk of the compiler (perhaps not a bug, but a quirk).

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

Sidebar

Related Questions

Possible Duplicate: Assuming 32bit ints So I read somewhere that int equals int32 in
Possible Duplicate: How does Python compare string and int? Can any one explain the
Possible Duplicate: Why does InputStream#read() return an int and not a byte? Issue regarding
Possible Duplicate: Using GetHashCode for getting Enum int value Is it safe to use
Possible Duplicate: What does the tilde (~) mean in C#? class ResourceWrapper { int
Possible Duplicate: C#, int or Int32? Should I care? Please any one let me
Possible Duplicate: Addition of two chars produces int Given the following C++ code: unsigned
Possible Duplicate: How does Python compare string and int? An intern was just asking
Possible Duplicate: Why does InputStream#read() return an int and not a byte? why return
Possible Duplicate: How do I serialize an enum value as an int? Hi, all!

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.