title: Reducing Bit Order Logic
body: <p>I have the following code, and I'm wondering if there's a more succinct, reduced way to write this code:</p>
  
  <p>(FontStyle is a .NET Enum with the Flags attribute)</p>
  
  <pre><code>lblPrompt.Font.Style = FontStyle.Regular;
  
  if (chkBold.Checked)
      lblPrompt.Font.Style |= FontStyle.Bold;
  if (chkItalics.Checked)
      lblPrompt.Font.Style |= FontStyle.Italic;
  if (chkUnderline.Checked)
      lblPrompt.Font.Style |= FontStyle.Underline;
  </code></pre>
  
  <p>I have a feeling the answer lies in correctly applying the and &amp; operator between CheckBox.Checked and the desired flag, similar to the following:</p>
  
  <pre><code>lblPrompt.Font.Style =
      (chkBold.Checked &amp; FontStyle.Bold)
      | (chkItalics.Checked &amp; FontStyle.Italic)
      | (chkUnderline.Checked &amp; FontStyle.Underline);
  </code></pre>
  
  <p>This does not work however because the compiler apparently does not like my direct application of the ampersand with a bool and a Flag/Enum type.</p>