Mega Code Archive

 
Categories / C# Tutorial / Data Type
 

Operators

using System;    class Example {    public static void Main() {      int val = 128;        for(int i = 0; i < 8; i++) {         for(int t=128; t > 0; t = t/2) {          if((val & t) != 0) Console.Write("1 ");           if((val & t) == 0) Console.Write("0 ");         }        Console.WriteLine();        val = val >> 1; // right shift      }    }  } 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1