End Google Ads 201810 - BS.net 01 --> Hi

I'm having a problem solving this problem.
I have an XML file describing how the different types (double, float, int and so on) should be interprettet, or how many bits the size of them should be. My application reads the XML and then have to cast for example a double to a float or an int to a short, based on the configuration. Afterward, the new casted or converted value has to converted to a byte array of the size of the type defined in the XML file.

I will just give an example to clarify.

1. Double value received.
2. Convert double value based on the conversion size in XML, double is cast / converted to float.
3. Create byte array from casted / converted value.

I can convert the value without problems using Convert.ChangeType(doubleValue,Type.GetType("System.Single")), but this give an object that I do not know how to make to a byte array of the correct size (32 bits).

Can anyone help me with solving the problem with converting / casting a double to a specific type defined in a XML file and converting this to a byte array ?
What I'm interrested in is the byte array being the size defined in the XML with signed values.

Thanks alot

Dennis