How to use RightShift Operators in C#?
Answers
Answered by
0
Answer:
In Bitwise right shift operator the value of the left operand is moved right by the number of bits specified by the right operand.
In the below code, we have the value:
60 i.e. 0011 1100
On the right shift:
c = a >> 2;
It converts into 15 after right shift twice:
15 i.e. 0000 1111
You can try to run the following code to implement Bitwise right shift operator in C#:
using System;
using System.Collections.Generic;
using System.Text;
namespace Demo {
class toBinary {
static void Main(string[] args) {
int a = 60; /* 60 = 0011 1100 */
int b = 0;
c = a >> 2; /* 15 = 0000 1111 */
Console.WriteLine("Value of b is {0}", b);
Console.ReadLine();
}
}
}
Explanation:
Similar questions