Convert byte array to decimal : decimal convert back and forth « Data Type « C# / CSharp Tutorial






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());
            }
        }

    }
}
285998345545.563846696








2.32.decimal convert back and forth
2.32.1.Convert a decimal to a byte array and display
2.32.2.Convert byte array to decimal
2.32.3.Converts Decimal numbers to SByte values using the explicit Decimal to SByte conversion.