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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:20:03+00:00 2026-05-29T09:20:03+00:00

Currently, Enum.Parse supports only the comma as the value separator, so that MemberOne,MemberThree will

  • 0

Currently, Enum.Parse supports only the comma as the value separator, so that

MemberOne,MemberThree

will be correctly parsed but

MemberOne|MemberThree

won’t. Is there any way to force Enum.Parse to accept other characters as the separator (for example, the ‘|‘) without using String.Replace on the expression parameter?

  • 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-29T09:20:03+00:00Added an answer on May 29, 2026 at 9:20 am

    You could add your own custom helper method for the Enum class like this:

    public static class EnumHelpers
    {
        public static object Parse(Type enumType, string value, char separator)
        {
            return Enum.Parse(enumType, value.Replace(separator, ','));
        }
    }
    

    Then use it like this:

    myEnum x = (myEnum)EnumHelpers.Parse(typeof(myEnum), "a|b", '|');
    

    I'm not really sure if this meets your criteria - it's still using string.Replace, but you don't have to use it in the parameter.

    You could also have a method like this which could accept multiple options without specifying the separator on each call:

    private const char[] additionalSeparators = new char[] { '|', '$', '#' };
    
    public static object Parse(Type enumType, string input)
    {
        string val = input;
        foreach(char c in additionalSeparators)
        {
            val = val.Replace(c, ',');
        }
        return Enum.Parse(enumType, val);
    }

    which could be called like this:

    myEnum x = (myEnum)EnumHelpers.Parse(typeof(myEnum), "a|b");
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a model Attend that will have a status column, and this
I am currently developing an approval routing WCF service that will allow an user
There is a nice class Enum from enum , but it only works for
I'm currently writing a helper function in VB.NET to convert an array of enum
So I have function that formats a date to coerce to given enum DateType{CURRENT,
I have written code to TryParse enum either by value or by its name
I need a Generic function to retrieve the name or value of an enum
Currently, I am using a type-safe enum class from Boost Vault : Which Typesafe
I am currently migrating my code from the old-style enum to enum class. The
I'm currently working on a Windows Forms GUI and I have a Combo that

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.