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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:29:57+00:00 2026-06-05T20:29:57+00:00

Consider [Flags] public enum State { IsCool = 0x1, SomethingElse = 0x2 } I

  • 0

Consider

   [Flags]
   public enum State
   {
      IsCool = 0x1,
      SomethingElse = 0x2
   }

I have a State someState and if some expression evaluates to true, I want to unset the IsCool flag of someState regardless of it being already set or unset. This means that I can’t really use someState ^= State.IsCool but what can I use instead?

  • 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-05T20:29:58+00:00Added an answer on June 5, 2026 at 8:29 pm

    You need to approach this the reverse way than when setting a flag: bitwise AND the current state with the complement of the flag you want to remove.

    someState &= ~State.IsCool;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following enum: [Flags] public enum MyEnum { Option1 = 0, Option2 =
I have the following enum: [Flags] public enum PostAssociations { None = 0x0, User
Consider the following class: class Foo { enum Flags {Bar, Baz, Bax}; template<Flags, class
Consider this: [Flags] enum Colors { Red=1, Green=2, Blue=4 } Colors myColor=Colors.Red|Colors.Blue; Currently, I'm
I'm creating a flags enumeration in C#, similar to the following: [Flags] public enum
Consider the following code: public interface A { public A another(); } public interface
Consider this code: enum { ERR_START, ERR_CANNOTOPENFILE, ERR_CANNOTCONNECT, ERR_CANNOTCONNECTWITH, ERR_CANNOTGETHOSTNAME, ERR_CANNOTSEND, }; char* ERR_MESSAGE[]
Consider a class that is supposed to make parameter suggestion, given some clues, and
please consider the following: I have a queue of objects represented as an array.
I have mysterious happenings in my code. Here's the snippet from the bean: public

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.