Most base types can be converted to a byte array, by calling BitConverter.GetBytes:
using System;
using System.Text;
using System.Globalization;
class Sample
{
public static void Main()
{
foreach (byte b in BitConverter.GetBytes(3.5))
Console.Write(b + " "); // 0 0 0 0 0 0 12 64
}
}
The output:
0 0 0 0 0 0 12 64
BitConverter also provides methods for converting in the other direction, such as ToDouble.