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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:45:58+00:00 2026-05-15T14:45:58+00:00

The application I’m working on has lots of enumerations. These values are generally selected

  • 0

The application I’m working on has lots of enumerations.

These values are generally selected from drop downs in the application.

What is the generally accepted way of storing the string description of these values?

Here is the current issue at hand:

Public Enum MyEnum
   SomeValue = 1
   AnotherValue = 2
   ObsoleteValue = 3
   YetAnotherValue = 4
End Enum

The drop down should have the following selections:

Some Value
Another Value
Yet Another Value (Minor Description)

Not all fit the name of the enumeration, (minor description on one is an example), and not all enumeration values are -current- values. Some remain only for backwards compatibility and display purposes (ie printouts, not forms).

This leads to the following code situation:

For index As Integer = 0 To StatusDescriptions.GetUpperBound(0)
   ' Only display relevant statuses.
   If Array.IndexOf(CurrentStatuses, index) >= 0 Then
      .Items.Add(New ExtendedListViewItem(StatusDescriptions(index), index))
   End If
Next

This just seems like it could be done better, and I’m not sure how.

  • 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-15T14:45:59+00:00Added an answer on May 15, 2026 at 2:45 pm

    You could use the Description attribute (C# code, but it should translate):

    public enum XmlValidationResult
    {
        [Description("Success.")]
        Success,
        [Description("Could not load file.")]
        FileLoadError,
        [Description("Could not load schema.")]
        SchemaLoadError,
        [Description("Form XML did not pass schema validation.")]
        SchemaError
    }
    
    private string GetEnumDescription(Enum value)
    {
        // Get the Description attribute value for the enum value
        FieldInfo fi = value.GetType().GetField(value.ToString());
        DescriptionAttribute[] attributes = 
            (DescriptionAttribute[])fi.GetCustomAttributes(
                typeof(DescriptionAttribute), false);
    
        if (attributes.Length > 0)
        {
            return attributes[0].Description;
        }
        else
        {
            return value.ToString();
        }
    }
    

    Source

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

Sidebar

Related Questions

Application has an auxiliary thread. This thread is not meant to run all the
Application : I am working on one mid-large size application which will be used
Application settings in Windows Forms is a convenient way to store application-wide properties. However,
My application is not all to complicated. It retrieves a single entity from a
Application.Run(form); Actually I tried to call this from my project. I got this exception.
APPLICATION DESCRIPTION : I am a new iPhone developer. I am working on an
Application.Run(new Main()); This line gives TypeInitializationException was unhandled after I switched from 3.5 to
Application has a tabhost managed through TabActivity. It has option to add tabs at
// Application Drupal 7 // Problem Background My website imports product data from a
My application has to detect that the device connected to the Wi-Fi network is

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.