C# numeric constants
<p>I have the following C# code:</p>

<pre>
  byte rule = 0;
  ...
  rule = rule | 0x80;
</pre>

<p>which produces the error: 
<em>Cannot implicitly convert type 'int' to 'byte'. An explicit conversion exists (are you missing a cast?)</em></p>

<p>[Update: first version of the question was wrong ... I misread the compiler output]</p>

<p>Adding the cast <strong>doesn't</strong> fix the problem:</p>

<pre>
  rule = rule | (byte) 0x80;
</pre>

<p>I need to write it as:</p>

<pre>
  rule |= 0x80;
</pre>

<p>Which just seems weird. Why is the |= operator any different to the | operator?</p>

<p>Is there any other way of telling the compiler to treat the constant as a byte?</p>

<hr>

<p><strong>@ Giovanni Galbo</strong> : yes and no.  The code is dealing with the programming of the flash memory in an external device, and logically represents a single byte of memory.  I could cast it later, but this seemed more obvious.  I guess my C heritage is showing through too much!</p>

<p><strong>@ Jonathon Holland</strong> : the 'as' syntax looks neater but unfortunately doesn't appear to work ... it produces:
<em>The as operator must be used with a reference type or nullable type ('byte' is a non-nullable value type)</em> </p>
