It's the same kind of thing.
The C code expects the bits to already be in the bottom of the integer. The C# code expects 8 bits per colour.
The C code is masking the unwanted bits out with ANDs whereas the C# code is shifting right first to remove the same bits.