title: Catching fallen-off bytes in bit shifting in C#
body: <p>If you want to know whether a particular bit is set in a byte, a simple AND mask can do the trick. I want to know if there is a faster way to achieve the same. As an example, bit shifting &lt;&lt; or >> returns the shifted number rather than the bit that just 'fell off'.</p>
  
  <p>If there is no alternative in managed code, would writing unsafe assembly make it faster? If so, please explain how.</p>
  
  <p>Context: This is for a complex algorithm that needs to be highly optimized for production code. I felt it necessary to clarify this to avoid the dreaded 'do your own homework' comments and/or vote downs.</p>