C# Programming - Operators - Discussion

Discussion Forum : Operators - General Questions (Q.No. 2)
2.
What will be the output of the C#.NET code snippet given below?
byte b1 = 0xF7;
byte b2 = 0xAB;
byte temp;
temp = (byte)(b1 & b2);
Console.Write (temp + " ");
temp = (byte)(b1^b2);
Console.WriteLine(temp);
163 92
92 163
192 63
0 1
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
33 comments Page 3 of 4.

Joao Lourenco said:   1 decade ago
@Sruthi You need to AND the numbers, not ADD them.

Bhargav Pandya said:   1 decade ago
Thanks Abhijit Marne.

Robin5480@gmail.com said:   1 decade ago
Thanks to Shruthi.

Anandhajothi.s said:   1 decade ago
How to work this problem ?

Bhavik said:   1 decade ago
Thank you sruti

Gggggg said:   1 decade ago
Thank you bhairav!

Bhairav said:   1 decade ago
Its right.

Sruthi said:   1 decade ago
(0xF7)its in hexadecimal lang convert it into binary then value is 11110111 similarly (0xAB)value is 10101011.

Add these two numbers you will get the value as 10100011 ie binary value convert into decimal ie 163, and

Subtract those two numbers you get the value as 01011100 decimal value is 92.

Vakul Saini said:   1 decade ago
Please please give me the description how is this 163 92 ?

Kavitha said:   1 decade ago
I couldn't understand that how it works. Please explain the steps.


Post your comments here:

Your comments will be displayed after verification.