Try this:
public int DoShift()
{
int newBit = 1 << (length - 1); // you can save it as class member
int result = Contents & 1;
int feedback = Contents & tapSequence;
Contents >>= 1;
while(feedback != 0) {
feedback &= feedback - 1;
Contents ^= newBit;
}
return result;
}
In addition, exist more efficient approach, named "reversed LSFR". It's idea - apply tapSequence to whole register just once, if result is 1.
See example: https://en.wikipedia.org/wiki/Linear_feedback_shift_register