using System;
using System.IO;
class MainClass
{
public static void Main()
{
byte[] b = null;
using (MemoryStream stream = new MemoryStream())
{
using (BinaryWriter writer = new BinaryWriter(stream))
{
writer.Write(285998345545.563846696m);
b = stream.ToArray();
}
}
using (MemoryStream stream = new MemoryStream(b))
{
using (BinaryReader reader = new BinaryReader(stream))
{
Console.WriteLine(reader.ReadDecimal());
}
}
}
}