Reputation: 425
Here is part of my code
ushort code = ...;
...
code <<= 1;
code |= (NextBit(ref isEndOfScan) << 0); //ERROR
bool NextBit(ref bool isEndOfScan)
returning bool
I am rewriting my code from c++ to c#.
I've tried to convert function result to int or write false
instead of 0
, but nothing helped.
I want to set 0 bit of variable code
.
Upvotes: 0
Views: 123
Reputation: 1500873
C++ allows some conversions that C# doesn't - particularly around Boolean values.
In this case, you can just use the conditional operator to treat the return value as 1 or 0:
code |= NextBit(ref isEndOfScan) ? 1 : 0;
Upvotes: 4