title: Negative flags in C#
body: <p>Hey, is there any way to store negative flags in C#? For example I have the following flags enum that represents some styles:</p>
  
  <pre><code>[Flags]
  public enum Styles
  {
      Default = 0,
      Bold = 1,
      Italic = 2
  }
  </code></pre>
  
  <p>Now I have multiple objects, those styles can be applied to, and later all related are combined (i.e. other object may inherit some previously set styles). In addition to that, I would like to define negative flags, that basically undo inherited styles. So if the style was previously set to <code>Styles.Bold | Styles.Italic</code> and the object inherits that style but has a negative <code>Styles.Bold</code> flag set, then the result should be just <code>Styles.Italic</code>.</p>
  
  <p>Is there any mechanism that already does this? I basically though of two ways now: First is defining <code>NotXY</code> enum values, that are then somehow parsed to eliminate the <code>XY</code> values if set.</p>
  
  <p>The other is simply defining two fields, positive and negative flags, where the negative flags are specially defined in an extra field and I get the resulting flags by simply doing <code>positiveFlags ^ negativeFlags</code>.</p>
  
  <h3>edit:</h3>
  
  <p>If this wasn't clear, I need to store each of those intermediate objects' styles. So it could be for example like this:</p>
  
  <pre><code>object1: Default
  object2: Bold
  object3: -Bold Italic
  </code></pre>
  
  <p>And if object3 also inherits the values of 1 and 2, then the final result should be just <code>Italic</code>.</p>
  
  <p>Another example in response to Kieren Johnstone's question, and per my statement in the comment that negative values only apply on the current level:</p>
  
  <pre><code>1: Bold
  2: -Bold -Italic
  3: Italic
  </code></pre>
  
  <p>2 eliminates both Bold and Italic from previous objects, but then shouldn't apply any further (positive values should though), so the final value would be <code>Italic</code> again.</p>