---
title: "Basic Concept and program for Bit-Wise Operation"  
description: "Today's world is a digital world. All the computerized data manipulation is done in binary format because it is directly implemented in digital electr"  
author: "Abhishek Srivasatava"  
published: 2016-09-13  
updated: 2018-03-16  
canonical: https://www.mindstick.com/blog/11204/basic-concept-and-program-for-bit-wise-operation  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# Basic Concept and program for Bit-Wise Operation

Today's world is a [digital world](https://answers.mindstick.com/qa/99230/how-digital-world-washed-out-gender-discrimination-from-society). All the computerized [data manipulation](https://www.mindstick.com/forum/1919/image-manipulation-c-sharp) is done in [binary format](https://answers.mindstick.com/qa/51767/how-to-convert-a-number-into-binary-format) because it is directly implemented in digital electronic circuitry using logic gates. The binary [system](https://www.mindstick.com/articles/23411/the-most-effective-method-to-find-the-perfect-small-business-phone-system-for-your-business) is used internally by almost all [modern](https://www.mindstick.com/articles/13064/advanced-features-in-the-modern-wireless-keyboards) computers and computer-based devices.\

For C#, below is the bit-wise [operators](https://www.mindstick.com/articles/716/php-operators) which are used to manipulate the data:

**[Operator](https://www.mindstick.com/blog/144/union-intersection-and-except-operator-in-sql-server) Description** \

& Binary AND Operator

| Binary OR Operator

^ Binary XOR Operator

~ Binary Ones Complement Operator

<< Binary Left Shift Operator

>> Binary Right Shift Operator

Here is the complete code to implement these operators:

```
 using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApplication5{    class Program    {        static void Main(string[] args)        {            int a, b, c, d;            Console.Write("Enter the First Number : ");            a = Convert.ToInt32(Console.ReadLine());            Console.Write("Enter the Second Number : ");            b    = Convert.ToInt32(Console.ReadLine());            c = a& b;              Console.WriteLine("Result for the AND operator is {0}", c);            c = a | b;            Console.WriteLine("Result for the OR operator  is {0}", c);            c = a ^ b;            Console.WriteLine("Result for the XOR operator is {0}", c);            c = ~a;            d = ~b;            Console.WriteLine("Result for the Binary Ones Complement Operator of 1st number is {0} and for 2nd is {1}", c,d);            c = a << 2;            d = b<< 2;            Console.WriteLine("Result for the Binary Left Shift Operaton of 1st number is {0} and for 2nd is {1}", c,d);            c = a>> 2;            d = b>>  2;            Console.WriteLine("Result for the Binary Right Shift Operator of 1st number is {0} and for 2nd is {1}", c,d);            Console.ReadLine();        }    }}
```

![Basic Concept and program for Bit-Wise Operation](https://www.mindstick.com/blogs/2d99e283-5547-4fef-8523-86a92a7b1b72/images/e90b8534-222b-4cdc-8254-35d5871b8a16.png)\

\

---

Original Source: https://www.mindstick.com/blog/11204/basic-concept-and-program-for-bit-wise-operation

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
