title: Enum as Flag using, setting and shifting
body: <p>I have two flags:</p>
  
  <pre><code>[Flags]
  enum Flags
  {
    A = 1,
    B = 2
  };
  </code></pre>
  
  <p>I set them like this:</p>
  
  <pre><code>Mode = Flags.A | Flags.B; // default value
  for(int i = 0; i &lt; args.Length; i++) {
  switch(args[i])
  {
    case "--a":
    {
      if ((Mode &amp; Flags.A) == Flags.A &amp;&amp; (Mode &amp; Flags.B) == Flags.B) 
       // both, default assume
      {
        Mode = Flags.A; // only A
      }
      else
      {
        Mode |= Flags.A; // append A
      }
      break;
    }
    case "--b":
    {
      if ((Mode &amp; Flags.A) == Flags.A &amp;&amp; (Mode &amp; Flags.B) == Mode.B)
      {
        Mode = Flags.B;
      }
      else
      {
        Mode |= Flags.B;
      }
      break;
    }
  } }
  </code></pre>
  
  <p>and use them later like this:</p>
  
  <pre><code>if((Mode &amp; Flags.A) == Flags.A)
  {
   //
  }
  if((Mode &amp; Flags.B) == Flags.B)
  {
   //
  }
  </code></pre>
  
  <p>Major reservation: Both flags may be set. Or just one, in this case only one part of code is executed.</p>
  
  <p>Is my code good? What is the best way to setup flags?</p>
  
  <p><strong>Upd</strong>:
  Is this less ugly then first, how do you think?</p>
  
  <pre><code>Mode = 0; // default value now is empty
  for(int i = 0; i &lt; args.Length; i++) {
  switch(args[i])
  {
    case "--a":
    {
      Mode |= Flags.A;
      break;
    }
    case "--b":
    {
      Mode |= Flags.B;
      break;
    }
  } }
  if(Mode == 0)
  {
    Mode = Flags.A | Flags.B; // if no parameters are given, setup both flags
  }
  </code></pre>