title: Using bitwise OR in enums
body: <p>I need to process the input from the user in a console application, and i need to allow only Z field numbers (... ,-1 , 0 , 1 ,...).<br>
  I have built that process char by char from the user, by keeping the last char i can verify that the order is correct. in the end the user must enter set of Z numbers for example<br>
  <code>-3 6 7 101 -500</code>.<br>
  My problem is with the comparison of the <code>LastInput</code> as <code>enum</code>, meaning i whant to check if the last input was <code>Numeric | Space | ...</code> please take a look at the code.  </p>
  
  <pre><code>public void Foo()
  {
      ConsoleKeyInfo key;
      var chars = new List&lt;char&gt;();
      NextChar last = NextChar.Space;
      var list = new List&lt;NextChar&gt; {last};
  
      do
      {
          key = Console.ReadKey(true);
          NextChar next = ProcessCharInput(key.KeyChar);
          switch (next)
          {
              case NextChar.None:
              if(key.Key != ConsoleKey.Enter)
              {
                  return;
              }
              continue;
  
              case NextChar.Space:
              if (last == (NextChar.Numeric))
              {
                  Console.Write(key.KeyChar);
                  last = next;
                  chars.Add(key.KeyChar);
              }
  
              break;
              case NextChar.Minus:
              if (last == (NextChar.Space))
              {
                  Console.Write(key.KeyChar);
                  last = next;
                  chars.Add(key.KeyChar);
              }
              break;
              case NextChar.Numeric:
              if (last == (NextChar.Numeric | NextChar.Minus | NextChar.Space))
              {
                  Console.Write(key.KeyChar);
                  last = next;
                  chars.Add(key.KeyChar);
              }
              break;
              default:
              throw new ArgumentOutOfRangeException();
          }
      }
      while (true);
  }
  
  [Flags]
  private enum NextChar
  {
      None = 0x0,
      Space = 0x1,
      Minus = 0x2,
      Numeric = 0x4
  }
  </code></pre>
  
  <p>I am guessing that i am doing something wrong with the enum because the input of <code>Numeric</code> and last is <code>Space</code> i cant get the <code>last == (NextChar.Numeric | NextChar.Minus | NextChar.Space)</code> to be true.</p>