bit operations

  • Thread starter Thread starter csharpula csharp
  • Start date Start date
C

csharpula csharp

A bit operatrions question:
how can u turn on bit (let's say #3) and leaving the other unchanged on
an int in one code line in c#?
 
int x = 0;
x |= 4;

Not sure how you number your bits, but if turning on #3 is equivalent to
binary value of 4, the above will serve.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top