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

The Archive Base Latest Questions

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

All, I have to do is: Find out whether a string is a valid

  • 0

All, I have to do is:

Find out whether a string is a valid Enum element and if so, return status.

something like, If I have an enum say Enum_Test which in turn consists of red, blue , green as its value.

Now, if blue is the element to be verified, I use something like

Enum_Test evalue;
if(Enum.TryParse(string_Verify, true, out evalue))  
{
        return true;
}

Or otherwise I have an another option,

if( Enum.IsDefined(typeof(Enum_Test), string_Verify))
{
        return true;
}

What is the advantages and pit falls in the above methods ?

  • 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-18T07:05:50+00:00Added an answer on June 18, 2026 at 7:05 am

    Advantage of the first method: It’s case insensitive: If you get blue, and there’s an enumeration member Blue, all will be fine.

    Advantage of the second method: It’s self-documenting: You don’t really want to parse, you want to check whether there is an enum value defined with a given name. So, in the second case, the name of the method more closely matches your intent.

    That said, if you want both advantages, use the first method and encapsulate it into a well-named method (e.g. IsEnumDefinedIgnoreCase).

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

Sidebar

Related Questions

Given a number, I have to find out all possible index-pairs in a given
I have set of c files and I need to find out whether a
How to find what all users have logged on my Windows Server 2003. What
I have looked all over the web and cannot find exactly what I am
I have searched all morning and yesterday afternoon and still cannot find an solution
I have looked all over the web and I can not find the information
I need to find all patrons that have at least 1 circulation record. Here's
Every place I have looked all I can find is how to read a
I am wondering how i can find all rows that have the same ID
Using t-sql, how can i find if all SQL Logins have strong passwords on

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.