<p>Given a FieldInfo object and an object, I need to get the actual bytes representation of the field. I know that the field is either <code>int,Int32,uint,short</code> etc.</p>

<p>How can I get the actual byte representation? BinaryFormatter.Serialize won't help, since it'll give me more information than I need (it also records type name etc.). The <code>Marshal</code> class does not seem to have facilities to use bytes array (but maybe I'm missing something).</p>

<p>Thanks</p>

Use BitConverter.GetBytes()
You'll first have to convert the value to it's native type, than use BitConverter to get the bytes:
```
```
byte[] Bytes;

if (valType == typeof(int))
{
    int intVal = (int) GetFieldValue(....);
    Bytes = BitConverter.GetBytes(intVval);
} 
else if (valType == typeof(long))
{
    int lngVal = (long) GetFieldValue(....);
    Bytes = BitConverter.GetBytes(lngVal);
} else ....
```
```