By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,338 Members | 1,350 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,338 IT Pros & Developers. It's quick & easy.

bit operations

P: n/a


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#?
*** Sent via Developersdex http://www.developersdex.com ***
Jan 28 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.

"csharpula csharp" <cs*******@yahoo.comwrote in message
news:e%****************@TK2MSFTNGP06.phx.gbl...
>

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#?
*** Sent via Developersdex http://www.developersdex.com ***

Jan 28 '07 #2

P: n/a
On Sun, 28 Jan 2007 12:54:19 -0800, csharpula csharp <cs*******@yahoo.com>
wrote:
>

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#?
*** Sent via Developersdex http://www.developersdex.com ***
And here's another Homework question...

Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
Jan 29 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.