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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:56:45+00:00 2026-06-12T03:56:45+00:00

I have a seemingly very basic question. I’m trying to decide whether or not

  • 0

I have a seemingly very basic question. I’m trying to decide whether or not constants strings would really be better than enums with MyEnum.ToString() called for a high performance application.

I have a class, enum, method like this…

    Public Enum MyEnum
        MyValue1
        MyValue2
    End Enum

    Public Class MyImportantClass

            Public Sub Foo(ByVal enumerationValue As MyEnum)

            ' Some code in here that needs to do this at some point
            Dim str As String = enumerationValue.ToString()

    End Sub

    End Class

I understand enumerationValue.ToString() has some performance issues. However, another developer suggested instead of using Enums, use Constant Strings. My problem is that the method parameter is then a string, and the caller can then pass whatever he wants. Not just any string will work, obviously, so this is a run-time bug.

Public Sub Foo(ByVal enumerationValue As String)

    ' Some code in here that needs to do this at some point
    '   Dim str As String = enumerationValue

End Sub

I want the safety of the enum, but the performance of a constant. As I said, I’m looking for a way to have my cake and eat it too.

  • 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-12T03:56:46+00:00Added an answer on June 12, 2026 at 3:56 am

    Stick with enum, it’s a lot more user frendly with passing as a parameter to a function. The IDE can pop-up the list of available items.

    To convert your enum to string, you could have a dictionnary of (Enum, String)

    or

    There’s some nice articles on how to put attributes on your enum, this way you can convert it to a string.

    Can I give an enum an attribute in VB.NET (like I can do in Java)?

    http://weblogs.asp.net/stefansedich/archive/2008/03/12/enum-with-string-values-in-c.aspx

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

Sidebar

Related Questions

So I'm trying to achieve something seemingly very basic in jQuery. I have a
Forgive me for this seemingly obvious question, but my searches have not revealed the
A seemingly trivial problem. I have a very basic page in Visual Studio 2010.
I am trying to implement something seemingly very simple, and I have been beating
Very basic seeming PHP question here... I have a page to which I'm already
I have a seemingly very small problem, but I can't find a solution for
I'm stuck with a seemingly very simple app that I'm trying to develop Basically,
So, this is a seemingly simple question, but I'm apparently very very dull. I
I have been going crazy over a seemingly easy question with Python: I want
I'm trying to tackle a problem that seemingly many Android developers have, which 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.