CSharp - Essential Types BitConverter Type

Introduction

Most base types can be converted to a byte array using BitConverter.GetBytes:

To convert byte array to base type, use BitConverter methods, such as ToDouble.

Demo

using System;
class MainClass/* ww  w .j a v  a2 s  .  co m*/
{
   public static void Main(string[] args)
   {
     foreach (byte b in BitConverter.GetBytes (123.5))
       Console.Write (b + " ");

   }
}

Result