unsigned char setBit(unsigned char ch, int n)
{
unsigned char mask = 1 << n;
return ch | mask;
}
I want to change n-bit with 1 in c# but I can't do it. I have only c++ examples.
unsigned char setBit(unsigned char ch, int n)
{
unsigned char mask = 1 << n;
return ch | mask;
}
I want to change n-bit with 1 in c# but I can't do it. I have only c++ examples.
In C++ the char
data type is one byte. In C# the equivalent type is byte
.
In C# the char
data type is a Unicode UTF-16 character (2 bytes).
byte setBit (byte b, int pos)
{
return (byte)(b | 1 << pos - 1);
}