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 2 of 4.

Gaurav said:   1 decade ago
0x is for indicating to the compiler that the no. is in hexadecimal.
A 0 is prefixed to indicate an octal no. .

Abhijit Marne said:   1 decade ago
11110111 & 10101011 = 10100011 ie 163
11110111 | 10101011 = 01011100 ie 92

Arif said:   1 decade ago
I don't understand please explain how to convert hexadecimal to decimal?

Savu said:   1 decade ago
I think @Arif provided the best explanation for this. Cheers buddy.

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

Rishabh said:   1 decade ago
Thanks sruti for explanation. You are great it was very easy.

Pooja Uttam said:   1 decade ago
128 64 32 16 8 4 2 1.
1 0 1 0 0 0 1 1 => 128+32+2+1 = 163.
(1)

Abi said:   1 decade ago
Whats the use of 0x?, why it is not included in calculation?

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

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


Post your comments here:

Your comments will be displayed after verification.