I don't know if this will work in Silverlight or not, but it does work in a Console application, and it doesn't require unsafe code.
If you can get your double values into a byte array, you can swap the bytes in the byte array to change endian-ness. The process can also be reversed, changing the byte array back into a double.
The code that follows illustrates how to convert between double and byte array, using System.InteropServices. The Main method returns two values in the console: 8 and 3.14159. The 8 indicates that a byte array of 8 bytes was successfully created from the double, and 3.14159 indicates that the double was correctly extracted from the byte array.
using System;
using System.IO;
using System.Text;
using System.Runtime.InteropServices;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double d = 3.14159d;
byte[] b = ToByteArray(d);
Console.WriteLine(b.Length);
Console.ReadLine();
double n = FrpmByteArray(b);
Console.WriteLine(n.ToString());
Console.ReadLine();
}
public static byte[] ToByteArray(object anything)
{
int structsize = Marshal.SizeOf(anything);
IntPtr buffer = Marshal.AllocHGlobal(structsize);
Marshal.StructureToPtr(anything, buffer, false);
byte[] streamdatas = new byte[structsize];
Marshal.Copy(buffer, streamdatas, 0, structsize);
Marshal.FreeHGlobal(buffer);
return streamdatas;
}
public static double FromByteArray(byte[] b)
{
GCHandle handle = GCHandle.Alloc(b, GCHandleType.Pinned);
double d = (double)Marshal.PtrToStructure(
handle.AddrOfPinnedObject(),
typeof(double));
handle.Free();
return d;
}
}
}