I have some old C code that is being converted to C#. There is a lot of bitwise operators such as this
const unsigned char N = 0x10;
char C;
.....
if (C & N)
{
.....
}
What would be the equivalent of this in C#? For example, the first line is invalid in C# as the compiler says there is no conversion from int to char. Nor is unsigned a valid operator in C#.
or
and
but be aware that
charin C is 1 byte, in C# it’s 2 bytes, so perhaps you should usebytebut perhaps you want to use flags, so you could use
enum:(note that Enum.HasFlag was introduced in C# 4.0)