Home > Article > Backend Development > Bitwise right shift operator in C#
#Bitwise operators act on bits and perform bitwise operations. In the bitwise right shift operator, the value of the left operand is shifted to the right by the number of bits specified by the right operand.
In the code below, we have the value -
60 i.e. 0011 1100
shift right %minus;
c = a >> 2;
shift right twice and convert to 15 -
15 i.e. 0000 1111
You can try running the following code to implement the 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(); } } }
The above is the detailed content of Bitwise right shift operator in C#. For more information, please follow other related articles on the PHP Chinese website!