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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:49:36+00:00 2026-06-18T06:49:36+00:00

Possible Duplicate: C# Enums – can my enums have friendly names? Cast string to

  • 0

Possible Duplicate:
C# Enums – can my enums have friendly names?
Cast string to enum with enum attribute

I have enum with byte values:

enum MarketingEventType : byte {MARKETING_CAMPAIGN, TELESALES, MARKETING_ACTIONS};

I would like to give for all element name, which I will get by ToSting() method.
For example:

MarketingEventType.TELESALES.ToString(); // I get "bla bla bla"
MarketingEventType.MARKETING_ACTIONS.ToString(); // I get "la la la"

It is possibe without change type of enum from BYTE to STRING?

  • 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-18T06:49:37+00:00Added an answer on June 18, 2026 at 6:49 am

    You can’t set an enum type to string. Valid base types are byte, sbyte, short, ushort, int, uint, long, and ulong.

    You can, however, use the Description attribute:

    enum MarketingEventType
    {
        [Description("bla bla bla")]
        TELESALES,
    }
    

    Retrieving the enum description is kind of a mess, but you can use this method (or even make an extension method out of it!):

    public static string GetEnumDescription(Enum value)
    {
        FieldInfo fi = value.GetType().GetField(value.ToString());
    
        DescriptionAttribute[] attributes =
            (DescriptionAttribute[])fi.GetCustomAttributes(
            typeof(DescriptionAttribute),
            false);
    
        if (attributes != null &&
            attributes.Length > 0)
            return attributes[0].Description;
        else
            return value.ToString();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Cast string to enum with enum attribute I have a enum like
Possible Duplicate: add values to enum Why enums in Java cannot inherit from other
Possible Duplicate: Enum with strings Is it possible to have string constants in enum
Possible Duplicate: JSON serialization of c# enum as string I have two classes as
Possible Duplicate: Finding an enum value by its Description Attribute I have a generic
Possible Duplicate: Mysql Select Enum Values I have set up a coloumn in Mysql
Possible Duplicate: Java - Convert String to enum I have a method that uses
Possible Duplicate: generating random enums Lets say I have the following: enum Color {
Possible Duplicate: How do I Convert a string to an enum in C#? Enums
Possible Duplicate: Get Enum from Description attribute I have an Enum that uses the

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.