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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:46:16+00:00 2026-05-24T03:46:16+00:00

I have an enum in my application to represent the saving options where the

  • 0

I have an enum in my application to represent the saving options where the user can save the image with lines drawn, circles, rectangles or any combination, so I declared an enum to represent the saving option.

enum SaveOption{lines,circles,rectangles};

How can I use operators to;

  • Add option to the options
  • Remove option from the options
  • 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-24T03:46:17+00:00Added an answer on May 24, 2026 at 3:46 am

    Mark the enum with the [Flags] attribute, and give each possible value a unique bit value:

    [Flags]
    enum SaveOption
    {
        lines = 0x1,
        circles = 0x2,
        rectangles = 0x4
    }
    

    Then you can do this sort of thing:

    SaveOption options;
    
    option = SaveOption.lines | SaveOption.circles; // lines + circles
    option |= SaveOptions.rectangles; // now includes rectangles
    option &= ~SaveOptions.circles; // now excludes circles
    

    Finally for ref, each option must have a value that is represented by a single bit, so in hex that’s 0x1, 0x2, 0x4, 0x8, then 0x10, 0x20, 0x40, 0x80 etc. Which is easier to remember than 1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536. Which is as far as I remember 🙂

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

Sidebar

Related Questions

I have: HttpContext.Current.Application.Get(KeyNames.EncodedKey).ToString() Where KeyNames is an enum. I can't use HttpContext . What
In my application, I have two equivalent enum s. One lives in the DAL,
I'm developing a C# application and I have the following enum: public enum TourismItemType
If you have an enum in your application and you only have a few
I have few different applications among which I'd like to share a C# enum.
public enum ObjectType { Country=0, Region=1, Province=2, City=3, Hotel=4 } I have two applications
I have enum like this [Flags] public enum Key { None = 0, A
i have enum public enum TypeImage { Img=0, Thumb=1 } i want in view
I have enum like this: public enum ObectTypes { TypeOne, TypeTwo, TypeThree, ... TypeTwenty
Say I have enum as follows (taken from MSDN example): enum Days {Sat=1, Sun,

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.