What will be the output of the following C# code? [code] public static void Main() { byte varA = 10; byte varB = 20;

Lâm Phung

New member
What will be the output of the following C# code?
Code:
 public static void Main() 
 {
     byte varA = 10;
     byte varB = 20;
     long result = varA | varB; 
     Console.WriteLine("{0}  OR  {1} Result :{2}", varA, varB, result);
     varA = 10;
     varB = 10;
     result = varA | varB;  
     Console.WriteLine("{0}  OR  {1} Result : {2}", varA, varB, result);
 }
A. 20, 10
B. 30, 10
C. 10, 20
D. 10, 10
 
Answer: b
Explanation: There are two kinds of Shift operations “Right Shift” and “Left Shift”. Right Shift operation is used for shifting the bit positions towards right side. Left Shift operation is used for shifting the bit positions towards left side. When Right Shift operations are done on a binary value the bits are shifted one position towards the right.
Output :
Code:
        10  OR  20 Result :30.
        10  OR  10 Result :10.
 

Tìm kiếm

Back
Top