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/*w  w  w.  j  av  a  2 s  . c  o m*/
{
   public static void Main(string[] args)
   {
     foreach (byte b in BitConverter.GetBytes (123.5))
       Console.Write (b + " ");

   }
}

Result