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

  • SEARCH
  • Home
  • 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 6587703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:57:07+00:00 2026-05-25T16:57:07+00:00

Possible Duplicate: C# int, Int32 and enum's C# allows you to set the underlying

  • 0

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

C# allows you to set the underlying type of an enumeration to long. But, how would you explain the difference in behavior when you try to compile the following two statements:

public enum Colors : long
{
   Blue = 512L,
   Purple = 1024L
}

and

public enum Colors : System.Int64
{
   Blue = 512L,
   Purple = 1024L
}

The first one compiles oK (with : long), while the second (with : System.Int64) wont compile – you get an error: Type byte, sbyte, short, ushort, int, uint, long, or ulong expected Note: Obviously, I understand the error message. What has me baffled is that I thought that “long” is more or less an alias for “Int64”

  • 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-25T16:57:08+00:00Added an answer on May 25, 2026 at 4:57 pm

    It is a limitation of the C# compiler and support for this on Enum will not be introduced. You will have to use long. Alex Turner (a Program Manager for Visual Basic and C#) at MSFT:

    Posted by Microsoft on 6/25/2010 at 8:53 AM
    Thanks for the suggestion for Visual Studio!

    As you point out, we could enable support for saying Int16 instead of int here, but this would not provide any extra expressiveness to C# programs (and it’s more characters to type!). We’d be unlikely to invest our resources to add this support to Enums.

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

Sidebar

Related Questions

Possible Duplicate: What is the difference between an int and a long in C++?
Possible Duplicate: What is the difference between an int and a long in C++?
Possible Duplicate: C# int, Int32 and enum's It could be a rather basic /
Possible Duplicate: Whats the main difference between int.Parse() and Convert.ToInt32 I would like to
Possible Duplicate: How do I serialize an enum value as an int? Hi, all!
Possible Duplicate: Difference between int[] array and int array[] I was sure that this
Possible Duplicate: PHP unexpected result of float to int type cast int((0.1+0.7)*10) = 7
Possible Duplicate: Difference between void main and int main? Alright, so I'm using bloodshed
Possible Duplicate: what is the difference between const int*, const int * const, int
Possible Duplicate: Assuming 32bit ints So I read somewhere that int equals int32 in

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.