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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:20:22+00:00 2026-05-22T21:20:22+00:00

In C, enums , internally equates to an integer. Therefore we can treat data

  • 0

In C, enums, internally equates to an integer. Therefore we can treat data types of enum as integer also.

How to achieve the same with C#?

  • 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-22T21:20:22+00:00Added an answer on May 22, 2026 at 9:20 pm

    Firstly, there could be two values that you’re referring to:

    Underlying Value

    If you are asking about the underlying value, which could be any of these types: byte, sbyte, short, ushort, int, uint, long or ulong

    Then you can simply cast it to it’s underlying type. Assuming it’s an int, you can do it like this:

    int eValue = (int)enumValue;
    

    However, also be aware of each items default value (first item is 0, second is 1 and so on) and the fact that each item could have been assigned a new value, which may not necessarily be in any order particular order! (Credit to @JohnStock for the poke to clarify).

    This example assigns each a new value, and show the value returned:

    public enum MyEnum
    {
        MyValue1 = 34,
        MyValue2 = 27
    }
    
    (int)MyEnum.MyValue2 == 27; // True
    

    Index Value

    The above is generally the most commonly required value, and is what your question detail suggests you need, however each value also has an index value (which you refer to in the title). If you require this then please see other answers below for details.

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

Sidebar

Related Questions

Why do people use enums in C++ as constants when they can use const
I have defined my Enums like this. public enum UserType { RESELLER(Reseller), SERVICE_MANAGER(Manager), HOST(Host);
I have nested class public class Enums { public enum WindowModeEnum { Edit, New
Apparently there's a list of blittable types and so far I don't see Enums
So I implemented my own form of Enum static classes so I can associate
This is my code: internal enum WindowsMessagesFlags { WM_EXITSIZEMOVE = 0x00000232, WM_DISPLAYCHANGE = 0x0000007e,
Are C++ enums signed or unsigned? And by extension is it safe to validate
How do you use enums in Oracle using SQL only? (No PSQL) In MySQL
Are C# enums typesafe? If not what are the implications?
Fun with enums in C#. Take one generic list that is created to store

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.