Do Bit shift left for int and long value in CSharp

Description

The following code shows how to do Bit shift left for int and long value.

Example


using System;//from  w  w  w .j  a  v a 2s  .  c o  m
class MainClass11
{
    static void Main()
    {
        int i = 1;
        long lg = 1;
        Console.WriteLine("0x{0:x}", i << 1);
        Console.WriteLine("0x{0:x}", i << 33);
        Console.WriteLine("0x{0:x}", lg << 33);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    C# Language »




C# Hello World
C# Operators
C# Statements
C# Exception