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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:26:10+00:00 2026-06-15T19:26:10+00:00

I am trying to understand a few things about Enums in general and how

  • 0

I am trying to understand a few things about Enums in general and how they can work with Chars specifically. Below is my example I am working from:

public enum AuditInteractionTypes
{
    Authorized = 'A',
    Created = 'C',
    Revised = 'R',
    Extracted = 'E',
    Deleted = 'D'
}

First, what’s the difference between declaring them enum AuditInteractionTypes or enum AuditInteractionTypes : char

Second, I have seen the numerous post’s about trying to use Enums with chars and how to “make” it work back and forth. Possible stupid question but why couldn’t I simply go back and forth as a string.

So, for example, Authorized = "A".

I have am using Linq To SQL as my DAL if that matters though I am asking, I hope, a broader level question not specific to my environment.

  • 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-15T19:26:11+00:00Added an answer on June 15, 2026 at 7:26 pm

    It dictates the underlying type that will be used for storage of the enumeration.

    When you use enum without anything else, it uses an int as the underlying storage type.

    When you use enum : <type>, it uses that type as the underlying storage type.

    In your case, you’re trying to make the underlying type of type char, but that’s not valid, according to the C# reference:

    The approved types for an enum are byte, sbyte, short, ushort, int, uint, long, or ulong.

    If you want to store char values, then you have two options.

    You could use an underlying type of ushort (it’s an unsigned 16-bit integer like char), like so:

    public enum AuditInteractionTypes : ushort
    {
        Authorized = 'A',
        Created = 'C',
        Revised = 'R',
        Extracted = 'E',
        Deleted = 'D'
    }
    

    char has an implicit conversion to ushort so the above works. Also, you can easily compare the two.

    If you want to use a string as the value then I’d recommend an enum-like class, like so:

    public static class AuditInteractionTypes
    {
        // You can make these static readonly if they are likely to change.
        public const string Authorized = "A";
        public const string Created = "C";
        public const string Revised = "R";
        public const string Extracted = "E";
        public const string Deleted = "D";
    }
    

    This class will then pretty much look the same as an enum and code the same way.

    Note, the same trick can be done with any type, but generally those types should be completely immutable. string fills this guideline nicely, being completely immutable (as are most system value types, and other value types, if you’ve designed them correctly).

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

Sidebar

Related Questions

I am new to Windbg and trying to understand a few things about value
I am trying to understand few things about using dylib and still studying, so
Possible Duplicate: Difference between (function(){})(); and function(){}(); I am trying to understand a few
Been trying to understand shared pointer for a few days now and it feels
I'm diving into iPhone OS development and I'm trying to understand how I can
Learning java server technologies, trying to clarify some things. There are few technologies that
I'm trying to print a few things, such as today's date, the day of
I'm trying to understand the basics of practical programming around character encodings. A few
I am trying to learn a few things from http://code.google.com/p/iosched/source/checkout . I wanted to
So I'm trying to implement things mentioned in Spring's 3.1 blog post about From

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.