When you find code on the internet in one language and try to use it in another, you have to understand three things:
1) The source language - in this case C or C++
2) The destination language - in this case C#
3) What the code does, and how it does it.
C and C++ look a lot like C# (understandable, C# was heavily influenced by them when it was designed) but they are very, very different languages which share some common syntax. You can't just lift C code and assume it will work unchanged in C#!
In this case, C does not have a concept of boolean values - no
true
or
false
. Instead, it treats any non-zero value as true, and any zero value as false. C# does have boolean values, and enforces their use.
So this:
if (crc_register & 0x0001)
needs to be changed to this:
if ((crc_register & 0x0001) != 0)
But ... you cannot expect the code even when it compiles to work exactly the same as the original unless you comply with all three of the conditions above!