2.3. Convert Basic Value Types to Byte Arrays
You need to convert basic value types to byte arrays.
The Shared methods of the System.BitConverter class provide a convenient mechanism for converting most basic value types to and from byte arrays. An exception is the Decimal type. To convert a Decimal type to or from a byte array, you need to use a System.IO.MemoryStream object.
How It Works
The Shared method GetBytes of the BitConverter class provides overloads that take most of the standard value types and return the value encoded as an array of bytes. Support is provided for the Boolean, Char, Double, Short, Integer, Long, Single, UShort, UInteger, and ULong data types. BitConverter also provides a set of Shared methods that ...