Binary Data Test : Binary Bit « Data Types « C# / C Sharp






Binary Data Test

Binary Data Test
   
using System;
using System.Net;
using System.Text;

public class BinaryDataTest
{
   public static void Main()
   {
      int test1 = 45;
      double test2 = 3.14159;
      int test3 = -1234567890;
      bool test4 = false;
      byte[] data = new byte[1024];
      string output;

      data = BitConverter.GetBytes(test1);
      output = BitConverter.ToString(data);
      Console.WriteLine("test1 = {0}, string = {1}", test1, output);

      data = BitConverter.GetBytes(test2);
      output = BitConverter.ToString(data);
      Console.WriteLine("test2 = {0}, string = {1}", test2, output);

      data = BitConverter.GetBytes(test3);
      output = BitConverter.ToString(data);
      Console.WriteLine("test3 = {0}, string = {1}", test3, output);

      data = BitConverter.GetBytes(test4);
      output = BitConverter.ToString(data);
      Console.WriteLine("test4 = {0}, string = {1}", test4, output);
   }
}

           
         
    
    
  








Related examples in the same category

1.Using the Bitwise Complement Operators with Various Data TypesUsing the Bitwise Complement Operators with Various Data Types
2.Obtaining the Most Significant or Least Significant Bits of a NumberObtaining the Most Significant or Least Significant Bits of a Number
3.Binary Network Byte OrderBinary Network Byte Order
4.Int binary
5.Get hash code for a byte array
6.Clone a byte array
7.Count the number of bit
8.Bit Helper
9.Bit shifting for int and long value
10.Returns how many bits are necessary to hold a certain number