
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are Left Shift and Right Shift Operators (>> and <<) in C#?
Bitwise Left shift operator
The left operands value is moved left by the number of bits specified by the right operand.
Bitwise Right shift operator
The left operands value is moved right by the number of bits specified by the right operand.
The following is an example showing how to work with Bitwise left and right shift operators −
Example
using System; namespace Demo { class Program { static void Main(string[] args) { int a = 60; /* 60 = 0011 1100 */ int b = 13; /* 13 = 0000 1101 */ int c = 0; c = a << 2; /* 240 = 1111 0000 */ Console.WriteLine("Value of c is {0}", c); c = a >> 2; /* 15 = 0000 1111 */ Console.WriteLine("Value of c is {0}", c); Console.ReadLine(); } } }
Output
Value of c is 240 Value of c is 15
- Related Questions & Answers
- Left Shift and Right Shift Operators in C/C++
- What are the >> and << operators in Python?
- Overloading stream insertion (<<) and extraction (>>) operators in C++
- What is right shift (>>) operator in Python?
- What is JavaScript Bitwise Left Shift(<<) Operator?
- What is unsigned Right Shift Operator (>>>) in JavaScript?
- What is JavaScript Bitwise Right Shift(>>) Operator?
- What is Bitwise Left Shift Operator (<<) in JavaScript?
- What is Bitwise Right Shift Operator (>>) in JavaScript?
- Explain JavaScript Bitwise NOT, Left shift and Right shift?
- '></a></li></ul><i>xssi</i>
- Are new HTML5 elements like <section> and <article> useless?
- Bitwise right shift operators in C#
- Why do we use cin >> and cout << in C++ ?
- What are shift operators in C++?
Advertisements