Right Shift Operator (>>) เลื่อนค่าของ operand ด้านซ้ายไปทางขวาตามจำนวนบิตที่ operand ด้านขวาระบุ
ตัวอย่าง
using System;
namespace OperatorsAppl {
class Program {
static void Main(string[] args) {
int a = 60; // 60 = 0011 1100
int b = 0;
b = a >> 2; // 15 = 0000 1111
Console.WriteLine("Right Shift Operator - Value of b is {0}", b);
Console.ReadLine();
}
}
}
ค่า a = 60 คือ 0011 1100 ใน binary
ใช้ a >> 2 เลื่อนบิตไปขวา 2 ตำแหน่ง
ผลลัพธ์ = 15 คือ 0000 1111