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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:36:13+00:00 2026-06-15T13:36:13+00:00

Is it possible to combine multiple enums together? Below is code sample of what

  • 0

Is it possible to combine multiple enums together? Below is code sample of what I would like to see:

enum PrimaryColors
{
   Red,
   Yellow,
   Blue
}

enum SecondaryColors
{
   Orange,
   Green,
   Purple
}

//Combine them into a new enum somehow to result in:
enum AllColors
{
   Red,
   Orange,
   Yellow,
   Green,
   Blue,
   Purple
}

It does not matter what order they are, or what their backing numbers are, I just want to be able to combine them.

For context, this is so that multiple classes for a program I am working on would have enums associated with what they do. My main program would read all of the enums available from each of the support classes and make a master list of available enums of available commands (the the enums are for).

Edit:
The reason for these enums is because my main program is reading in a list of commands to perform at certain times, and so I want to read in the file, see if the command in it is associated with one of my enums, and if it is, put it into a list of commands to perform.

  • 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-15T13:36:14+00:00Added an answer on June 15, 2026 at 1:36 pm

    Not sure I understand precisely. But you can make a List<> of all the values like this:

    var allColors = new List<Enum>();
    
    allColors.AddRange(Enum.GetValues(typeof(PrimaryColors)).Cast<Enum>());
    allColors.AddRange(Enum.GetValues(typeof(SecondaryColors)).Cast<Enum>());
    

    Instead of List<Enum> you could also use HashSet<Enum>. In any case, because you assign a PrimaryColor or SecondaryColor to a class type (namely System.Enum), you get boxing, but that’s just a technical detail (probably).

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

Sidebar

Related Questions

I have multiple NSString Arrays that I would like to combine into a single
Is it possible to combine a normal class with a partial class like this:
Possible Duplicate: Combine Multiple child rows into one row MYSQL I have following table,
I need a robust method that would combine multiple CSV files, taking into account
Possible Duplicate: MySQL Results as comma separated list Combine Multiple child rows into one
Possible Duplicate: Combine multiple results in a subquery into a single comma-separated value Concat
Is it possible to combine multiple PHP files via the command line and create
Possible Duplicate: How can I combine multiple rows into a comma-delimited list in Oracle?
Is it possible to combine multiple filters in Subsonic 2.1 to a shorter piece
Basically what I would like to do is run multiple (15-25) regex replaces 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.