bitwise exclusive OR

In this chapter you will learn:

  1. How to use bitwise OR operator

How to use bitwise OR operator

class MainClass// j a  v  a2s  .c o  m
{

  public static void Main()
  {

    byte byte1 = 0x9a;  // binary 10011010, decimal 154
    byte byte2 = 0xdb;  // binary 11011011, decimal 219
    byte result;

    System.Console.WriteLine("byte1 = " + byte1);
    System.Console.WriteLine("byte2 = " + byte2);

    
    result = (byte) (byte1 ^ byte2);
    System.Console.WriteLine("byte1 ^ byte2 = " + result);
  }

}

The code above generates the following result.

Next chapter...

What you will learn in the next chapter:

  1. How to use shift operators
  2. left shift
  3. right shift
  4. Use the shift operators to multiply and divide by 2
Home » C# Tutorial » 
C# operators
Arithmetic Operators
Assignment Operator
Remainder operator
Increment operator and decrement operators
Logic operators
Logic operator shortcut
Relational operators
sizeof
Ternary operator(The ? Operator)
typeof
Bitwise Operators
bitwise AND
bitwise OR
bitwise NOT
bitwise exclusive OR
Shift Operators
Precedence of the C# Operators